摘要:View Code 1 /* 2 dp[i][0] i位数字的数首位为0 3 dp[i][1] i位数字的数首位为1 4 5 */ 6 #include<stdio.h> 7 int main() 8 { 9 int n,k;10 int dp[20][2];11 while(~scanf("%d%d",&n,&k))12 {13 dp[1][0]=1; //只有一个数字的数首位为0那就只有0一个数 14 dp[1][1]=k-1;//只有一个数字的数首位不为0 ,对于k进制就只有k-1个数,除掉0嘛 15 ...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1178等差求和公式s=n(n+1)/2=n/2+n^2/2。。。sum=1+3+6+………………+i(i+1)(i+2)/6=1+(1+2)+(1+2+3)+…………(1+2+3+……n)=1/2+1^2/2+2/2+2^2/2+…………n/2+n^2/2=n(n+1)/2/2+n(n+1)(n+2)/6/2=n(n+1)(n+2)/6.
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1999思路:列举1000000能组成的所有数,1000以内最后一个素数是997,s(998*998)=998+1,998*998=996004.。。
阅读全文
摘要:View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<vector> 4 #define N 20010 5 using namespace std; 6 int dfn[N]; 7 int low[N]; 8 int instack[N]; 9 int stack[N]; 10 int belong[N]; 11 int in[N]; 12 int out[N]; 13 int visnum; 14 int cnt; 15 int stop; 16 17 int n,m; 18 vect
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1878View Code 1 #include<stdio.h> 2 #include<string.h> 3 int n,m; 4 int root[1002]; 5 int from[1002]; 6 int to[1002]; 7 int find(int x) 8 { 9 int res=x;10 while(x!=root[x])11 x=root[x];12 return x;13 }14 15 void merge(int x,int y)16 {17 ...
阅读全文
摘要:Drainage DitchesTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4652Accepted Submission(s): 2171Problem DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is
阅读全文