d首次尝试usaco的代码,第一题,就给我个超时的错误,应该是在文件哪里用时太多
下面为错误代码及出错情况,留作纪念。 time :2012.10.9
/* ID:ly-meng2 LANG: C TASK: ride */ #include <stdio.h> #include<stdlib.h> #include<string.h> #define Max 10 int turn(char i){ if('a'<=i&&i<='z') return i-'a'+1; else return i-'A'+1; } int GetMod(char *s){ int count; int sb=1; while(s[count]!='\0'){ sb*=turn(s[count]); } return sb%47; } int main () { FILE *fin = fopen ("ride.in", "r"); FILE *fout = fopen ("ride.out", "w"); char get1[Max]; char get2[Max]; while(1){ fscanf(fin,"%s",&get1); fscanf(fin,"%s",&get2); if(GetMod(get1)==GetMod(get2)) fprintf(fout,"GO\n"); else fprintf(fout,"STAY\n"); return 0; } }
转载文章请注明出处: http://www.cnblogs.com/menglei/