设为首页 加入收藏

TOP

hdu_2817_快速幂
2015-11-21 00:56:34 来源: 作者: 【 】 浏览:1
Tags:hdu_2817_ 快速

水~

#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
        
          #include
          using namespace std; #define MAX(x,y) (((x)>(y))?(x):(y)) #define MIN(x,y) (((x)<(y))?(x):(y)) #define N 500010 #define pi acos(-1.0) #define mod 200907 #define inf 100000000 typedef long long ll; typedef unsigned long long ull; ll powmod(ll a,ll n){ ll ans=1; ll tmp=a; while(n){ if(n&1){ ans*=tmp; ans%=mod; } n>>=1; tmp*=tmp; tmp%=mod; } return ans; } int main(){ int t; scanf(%d,&t); ll a,b,c,n,ans; while(t--){ scanf(%lld%lld%lld%lld,&a,&b,&c,&n); if(b*2==a+c){ ans=(a+(n-1)*(b-a)%mod)%mod; } else { ans=a*powmod(b/a,n-1)%mod; } printf(%I64d ,ans); } return 0; }
        
       
      
     
    
   

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇hdu1209(Clock) 下一篇hdu2093(考试排名)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: