hdu-2817 A sequence of numbers

费了我好长时间。。。。。
#include<stdio.h>
#include<string.h>
__int64 deal1(__int64 x,__int64 y){
	__int64 temp;
	temp=1;
    while(y){
    	if(y % 2 == 1)
    	   temp = temp * x % 200907;
		x = (x * x) % 200907; 
		y/=2;
    }
	return temp;
}
int main(){
    
	int i,j,n;
	__int64 a,b,c,d,k;
	scanf("%d",&n);
	while(n--){
		__int64 num;
		scanf("%I64d %I64d %I64d %I64d",&a,&b,&c,&d);
		
		//d=d%200907;
	//	printf("%d %d %d %d\n",number[1],number[2],number[3],number[3]);
		if((b-a) == (c-b)){
			k=b-a;
			num=a+(d-1)*k;
			num%=200907;
		   }
		else{
		      k=b/a;
		      num=(a * deal1(k,d-1)) % 200907;
			}
			// printf("%d ",number[i]);
		//	 printf("%d ",number[i]);
	//	for(i=1;i<=10;i++)
	//	  printf("%d ",number[i]);
		printf("%I64d\n",num);
	}
	return 0;
} 

你可能感兴趣的:(hdu-2817 A sequence of numbers)