hdu2817 2010.2.25

hdu2817 2010.2.25

1.  等差数列和等比数列的英文单词没认出来,对题意理解错误。

2.  学到了快速幂,这道题目,如果不用快速幂的话,一定会超时的。

 

#include <stdio.h>
#include <string.h>

__int64 ans,a,b,c,n;
__int64 x[120],lx;

void main()
{
	int k,t;
	scanf("%d",&t);
	for(k=1;k<=t;k++)
	{
		scanf("%I64d %I64d %I64d %I64d",&a,&b,&c,&n);
		if (b-a==c-b)
			printf("%I64d\n",((n-1)%200907*((b-a)%200907)+a%200907)%200907);
		else
		{
			__int64 r,i,m;
			r=b/a;
			ans=1;
			m=n-1;
			for(i=1;m>0;i++)
			{
				x[i]=m%2;
				m/=2;
			}
			for(i--;i>=1;i--)
			{
				ans=ans*ans%200907;
				if (x[i]>0)
					ans=ans*r%200907;
			}
			printf("%I64d\n",(ans*(a%200907))%200907);
		}
	}
}

A sequence of numbers

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 403    Accepted Submission(s): 122

 

 

Problem Description

Xinlv wrote some sequences on the paper along time ago, they might be arithmetic orgeometric sequences. The numbers are not very clear now, and only thefirst three numbers of each sequence are recognizable. Xinlv wants to know somenumbers in these sequences, and he needs your help.

 

 

Input

The first line contains an integer N,indicting that there are N sequences. Each of the following N lines containfour integers. The first three indicating the first three numbers of thesequence, and the last one is K, indicating that we want to know the K-thnumbers of the sequence.

 

You can assume 0 < K <= 10^9, and theother three numbers are in the range [0, 2^63). All the numbers of thesequences are integers. And the sequences are non-decreasing.

 

 

 

Output

Output one line for each test case, thatis, the K-th number module (%) 200907.

 

 

Sample Input

2

1 2 3 5

1 2 4 5

 

 

Sample Output

5

16

 

 

Source

2009 Multi-University Training Contest 1 -Host by TJU

 

 

Recommend

gaojie

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值