#include <stdio.h>
#include <stdlib.h>
long long f[1010][1010];
long long times(long long a,int e)
{
long long res = 1;
while(e > 0)
{
res = (res * a) % 10007;
e --;
}
return res;
}
void combination()
{
int i,j;
for(i = 0;i < 1010;i ++)
{
f[i][0] = 1;
for(j = 1;j <= i;j ++)
{
f[i][j] = (f[i - 1][j] + f[i - 1][j - 1]) % 10007;
}
}
}
int main()
{
long a,b,k,m,n;
scanf("%ld%ld%ld%ld%ld",&a,&b,&k,&n,&m);
combination();
printf("%lld\n",((f[k][m] * times(a,n)) % 10007) * times(b,m) % 10007);
return 0;
}
#include <stdlib.h>
long long f[1010][1010];
long long times(long long a,int e)
{
long long res = 1;
while(e > 0)
{
res = (res * a) % 10007;
e --;
}
return res;
}
void combination()
{
int i,j;
for(i = 0;i < 1010;i ++)
{
f[i][0] = 1;
for(j = 1;j <= i;j ++)
{
f[i][j] = (f[i - 1][j] + f[i - 1][j - 1]) % 10007;
}
}
}
int main()
{
long a,b,k,m,n;
scanf("%ld%ld%ld%ld%ld",&a,&b,&k,&n,&m);
combination();
printf("%lld\n",((f[k][m] * times(a,n)) % 10007) * times(b,m) % 10007);
return 0;
}
不过考试的时候这道题我只得了60分,也许是因为没有使用long long型吧。
No comments:
Post a Comment