浙大ACM ZOJ Problem Set - 3690
http://acm.zju.题目链接
题目:
There are n people standing in a row. And There are m numbers, 1.2...m. Every one should choose a number. But if two persons standing adjacent to each other choose the same number, the number shouldn't equal or less than k. Apart from this rule, there are no more limiting conditions.
And you need to calculate how many ways they can choose the numbers obeying the rule.
Input
There are multiple test cases. Each case contain a line, containing three integer n (2 ≤ n ≤ 108), m (2 ≤ m ≤ 30000), k(0 ≤ k ≤ m).
Output
One line for each case. The number of ways module 1000000007.
Sample Input
4 4 1
Sample Output
216
这是英文.大家用翻译软件大概能知道大概意思,还有就是输出的时候要取余1000000007
还有就是我的代码
程序代码:
#include"stdio.h" #define MM 1000000007 __int64 mk(int m,int k); int main() { int n,m,k,i; __int64 s,su; while(scanf("%d%d%d",&n,&m,&k)!=EOF) { s=mk(m,k); for(i=1,su=1;i<=n-1;i++) { su*=s; su=su%MM; } printf("%I64d\n",su); } return 0; } __int64 mk(int m,int k) { int i; __int64 su; for(i=1,su=0;i<=m;i++) { if(i-k-1>0) su+=i-k-1; if(m-i-k>0) su+=m-i-k; } return su; }
我自己编译没有错误
但交上去就说我编译错误
错误说明是
p.c:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'mk'
p.c: In function 'main':
p.c:19: error: '__int64' undeclared (first use in this function)
p.c:19: error: (Each undeclared identifier is reported only once
p.c:19: error: for each function it appears in.)
p.c:19: error: expected ';' before 's'
p.c:22: error: 's' undeclared (first use in this function)
p.c:22: warning: implicit declaration of function 'mk'
p.c:23: error: 'su' undeclared (first use in this function)
这有点看不懂
求解释
[ 本帖最后由 Magic_July 于 2013-5-5 21:04 编辑 ]