USACO Your Ride Is Here

//考察点: 文件操作
//思路: 写一个子函数用来计算每个单词的val就行
//提交情况: 1AC
//收获: 字符串数组最后有一个结束符 不要算错长度
//经验
//ACcode:
/*
ID: qiuqiyu1
PROG: ride
LANG: C++
*/
#include
< stdio.h >
#include
< string .h >
int  val( char  a[])
{
    
int  pro,i,len;
    pro
= 1 ;
    len
= strlen(a);
    
for (i = 0 ;i < len;i ++ )
    {
        pro
= (pro * (a[i] - ' A ' + 1 )) % 47 ;
    }
    
return  pro;
}

int  main()
{
    freopen(
" ride.in " , " r " ,stdin);
    freopen(
" ride.out " , " w " ,stdout);
    
char  a[ 7 ],b[ 7 ];
    scanf(
" %s " ,a);
    getchar();
    gets(b);
    printf(val(a)
== val(b) ? " GO\n " : " STAY\n " );
    
return   0 ;
}

你可能感兴趣的:(USACO Your Ride Is Here)