zoukankan      html  css  js  c++  java
  • 【USACO】初次尝试的错误your ride is here超时

    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/
  • 相关阅读:
    各种排序
    最大子数组的和与积
    字符串距离
    二叉树的基本操作
    C++11创建线程的几种方式
    二分查找
    汉诺塔问题
    读写锁实现
    全排列
    数字转汉字
  • 原文地址:https://www.cnblogs.com/menglei/p/2716802.html
Copyright © 2011-2022 走看看