标签:函数 const str hdu tom name problem acm bit
http://acm.hdu.edu.cn/showproblem.php?pid=2072
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10; char s[100][100]; char a[maxn]; int A(int x,int y)//判断字符串是否相等 相等返回 0 ,不等返回 1 { int cnt=0; int len1=strlen(s[x]); int len2=strlen(s[y]); if(len1==len2) { for(int i=0; i<len1; i++) { if(s[x][i]!=s[y][i]) return 1; } return 0; } return 1; } int main() { while(gets(a))//i 行 { int ans=0; int n=0; if(a[0]==‘#‘) break; int len=strlen(a); a[len]=‘ ‘; len++; a[len]=‘\0‘; for(int i=0; i<len; i++) { if(a[i]!=‘ ‘) for(int j=i; j<len; j++) { if(a[j]!=‘ ‘) continue; else { n++; for(int zzt=i; zzt<j; zzt++) { s[n][zzt-i]=a[zzt]; } s[n][j-i]=‘\0‘; i=j; break; } } } //cout<<n<<endl; //for(int i=1;i<=n;i++) //cout<<s[i]<<" "<<endl; for(int i=1; i<=n; i++) { int add=1; for(int j=i-1; j>0; j--) { add*=A(i,j); } if(add==1) ans++; } printf("%d\n",ans); } return 0; }
标签:函数 const str hdu tom name problem acm bit
原文地址:https://www.cnblogs.com/zlrrrr/p/9248403.html