hdu_3063_Play game

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3063

题意:中文题,说的很清楚,不解释

题解:公式题,具体看代码

 1 #include<stdio.h>
 2 #include<string.h>
 3 #define mod 4*9999
 4 /*
 5 需要用到的公式:
 6 1*2*3+2*3*4+3*4*5+...+n*(n+1)(n+2)= (n*(n+1)*(n+2)*(n+3))/4
 7 (a + b) % p = (a % p + b % p) % p
 8 (a *b) % p = (a % p * b % p) % p
 9 (a/b)%p=(a%(b*p))/b
10 */
11 int main(){
12     __int64 n,i,s,sum;char str[101];
13     while(~scanf("%s",str)){
14         s=strlen(str);sum=0;
15         for(i=0;i<s;i++)
16         sum=(sum*10+str[i]-'0'),sum%=mod;
17         n=sum*(sum+1)*(sum+2)*(sum+3)/4;
18         printf("%I64d
",n%9999);
19     }
20     return 0;
21 }
View Code
原文地址:https://www.cnblogs.com/bin-gege/p/5696174.html