题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2467
大水题。
#include<iostream> #include<cstdio> using namespace std; typedef long long ll; const int Mod=2007; int t; ll n; long long pw(int k) { long long ret=1,tmp=5; while(k) { if(k&1)ret=(ret*tmp)%Mod; k>>=1; tmp=(tmp*tmp)%Mod; } return ret; } int main() { scanf("%d",&t); while(t--) { scanf("%lld",&n); printf("%lld ",(n*4*pw(n-1)%2007)); } return 0; }