#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long ll;
const int mod = 10007;
int T,cas=1,n,ans;
int pow_mod(int x, int y)
{
int ret = 1;
while (y)
{
if (y&1) ret=(ret*x)%mod;
x=(x*x)%mod;
y>>=1;
}
return ret;
}
int x,y,d;
void exgcd(int a,int b)
{
if(b==0)
{
x=1;
y=0;
d=a;
}
else
{
exgcd(b,a%b);
int t=x;
x=y;
y=t-a/b*x;
}
}
int main()
{
scanf("%d",&T);
while (T--)
{
scanf("%d",&n);
ans=(pow_mod(n,74)+pow_mod(n,20)*6+pow_mod(n,38)*9+pow_mod(n,26)*8)%mod;
exgcd(24,mod);
ans=ans*((x+mod)%mod)%mod; //欧几里得求逆元
// ans=(ans*pow_mod(24,mod-2))%mod; //费马定理求逆元,速度快点
printf("Case %d: %d\n",cas++,ans);
}
return 0;
}
tjut 4633
最新推荐文章于 2019-01-19 10:52:00 发布