摘要:
题目链接继续水过。。。 1 #include <stdio.h> 2 #include <string.h> 3 #define N 30010 4 #define eps 0.00000001 5 long long p1[N],p2[N]; 6 int main() 7 { 8 int a[6] = {1,5,10,25,50}; 9 int i,j,k,n;10 p1[0] = 1;11 for(i = 0; i <= 4; i ++)12 {13 for(j = 0; j <= 30000; j ++)14 {1... 阅读全文
摘要:
题目链接和POJ2406差不多,不过用暴力去找,会超时。 1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 #define N 1000001 5 char str[N]; 6 int next[N]; 7 int main() 8 { 9 int i,j,len,d,a = 0;10 while(scanf("%d%*c",&len)!=EOF)11 {12 a ++;13 if(len == 0)break;14 scanf("%s&qu 阅读全文
摘要:
题目链接预处理改一下,就OK了。。。我竟然敲错模版了。。。3Y。一种是暴力,一种更巧妙。直接取余判断 1 #include <stdio.h> 2 #include <string.h> 3 #define N 1000001 4 char str[N]; 5 int next[N]; 6 int main() 7 { 8 int i,j,len,d; 9 while(scanf("%s",str)!=EOF)10 {11 if(str[0] == '.')break;12 len = strlen(str);13 nex... 阅读全文
摘要:
题目链接第一个KMP,纪念纪念。。。虽然比着模版打的,理解模版,真的好短。 1 #include <stdio.h> 2 #include <string.h> 3 char str1[10001],str2[1000001]; 4 int next[10001]; 5 int main() 6 { 7 int t,len1,len2,num,i,j; 8 scanf("%d",&t); 9 while(t--)10 {11 scanf("%s%s",str1,str2);12 len1 = strlen(str1);13 阅读全文