Java-POJ1002-487-3279(含c++代码)
Java 的读入还不熟练,解决不了空行的问题,还是只能用c++ A掉,唉~
之后要把这个坑补掉
解决了,开心(*^▽^*)以下是AC的Java代码
以下是C++代码
1 #include<cstdio> 2 int map[10000000]; 3 void read() { 4 char s[200]={0}; 5 scanf("%s",s); 6 //printf("%s\n",s); 7 int id=0; 8 for(int i=0,f=1;; i++) { 9 //printf("%c\n",s[i]); 10 if(s[i]=='-'||s[i]=='Q'||s[i]=='Z')continue; 11 id*=10; 12 if('A'<=s[i]&&s[i]<='Z') { 13 if(s[i]=='S')id+=7; 14 else if(s[i]-'B'<=1)id+=2; 15 else if(s[i]-'E'<=1)id+=3; 16 else if(s[i]-'H'<=1)id+=4; 17 else if(s[i]-'K'<=1)id+=5; 18 else if(s[i]-'N'<=1)id+=6; 19 else if(s[i]-'Q'<=1)id+=7; 20 else if(s[i]-'U'<=1)id+=8; 21 else if(s[i]-'X'<=1)id+=9; 22 } 23 else id+=s[i]-'0'; 24 f++; 25 if(f>7)break; 26 } 27 map[id]++; 28 } 29 void put(int x) { 30 int a[10]={0}; 31 for(int i=7;i>=1;i--){ 32 a[i]=x%10; 33 x/=10; 34 } 35 for(int i=1;i<=7;i++){ 36 printf("%d",a[i]); 37 if(i==3)printf("-"); 38 } 39 } 40 int main() { 41 int n; 42 bool f=1; 43 scanf("%d",&n); 44 for(int i=1; i<=n; i++) read(); 45 for(int i=0; i<=9999999; i++) { 46 if(map[i]>1) { 47 put(i); 48 printf(" %d\n",map[i]); 49 f=0; 50 } 51 } 52 if(f)puts("No duplicates."); 53 return 0; 54 }
~~Jason_liu O(∩_∩)O