akly

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  1 Posts :: 0 Stories :: 0 Comments :: 0 Trackbacks

常用链接

留言簿

我参与的团队

搜索

  •  

最新评论

 

Examples:

Input OutPut
COMETQ
HVNGAT
GO
ABSTAR
USACO
STAY

Code:

 1/*
 2ID:         yy2alan2
 3PROG:       ride
 4LANG:       C++
 5*/

 6#include <fstream>
 7#include <string>
 8#include <cstring>
 9
10using namespace std;
11
12int main( ){

13    ofstream fout("ride.out");
14    ifstream fin("ride.in");

15    const int MaxLen = 10
16    char cometName[MaxLen + 1];
17    char groupName[MaxLen + 1];

18    fin.getline(cometName, MaxLen);
19    fin.getline(groupName, MaxLen);

20    int cometLen = strlen(cometName);
21    int groupLen = strlen(groupName);
22    int cometNum = 1;
23    int groupNum = 1;

24    for ( int i = 0; i < cometLen; i++)
25        cometNum = cometNum * (cometName[i]-'A'+1);
26    for ( int i = 0; i < groupLen; i++)
27        groupNum = groupNum * (groupName[i]-'A'+1);   

28    if ( groupNum %  47 == cometNum % 47 ){
29        fout << "GO" << endl;
30    }
else{
31        fout << "STAY" << endl;
32    }

33    fout.close();
34    fin.close();
35    return 0;
36}

37
posted on 2008-12-03 22:01 akly 阅读(1294) 评论(0)  编辑 收藏 引用 所属分类: USACO

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理