bzoj2467生成树

题目: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",(n*4*pw(n-1)%2007));
    }
    return 0;
}
View Code

 

posted on 2018-03-01 15:43  Narh  阅读(92)  评论(0编辑  收藏  举报

导航