USACO section1.1 ride
1 /* 2 ID: vincent63 3 LANG: C 4 TASK: ride 5 */ 6 #include <stdio.h> 7 #include<string.h> 8 int main () { 9 FILE *fin = fopen ("ride.in", "r"); 10 FILE *fout = fopen ("ride.out", "w"); 11 12 char a[10]; 13 char b[10]; 14 char go[]="GO\n"; 15 char stay[]="STAY\n"; 16 int i; 17 int sum1=1; 18 int sum2=1; 19 fgets(a,10,fin); 20 fgets(b,10,fin); 21 //int len=strlen(a); 22 //printf("strlen:%d\n",len); 23 for(i=0;i<strlen(a)-1;i++){ 24 int temp=a[i]-64; 25 sum1=temp*sum1; 26 //printf("%d\n",temp); 27 } 28 for(i=0;i<strlen(b)-1;i++){ 29 int temp=b[i]-64; 30 sum2=temp*sum2; 31 //printf("%d\n",temp); 32 } 33 if((sum1%47)==(sum2%47)){ 34 //printf("go\n"); 35 fputs(go,fout); 36 }else{ 37 fputs(stay,fout); 38 } 39 //printf("%s%s\n",a,b); 40 41 return 0; 42 }