USACO-Section1.1 Your Ride Is Here [模拟]
来源:互联网 发布:linux检索文件内容 编辑:程序博客网 时间:2024/06/03 05:33
2017-05-19
题目大意:
给定两个字符串S1、S2,长度都在6以内。字符’A’对应数字1, 字符’B’对应数字2, 以此类推。对于给定字符串,计算该字符串的所有字母对于数字的乘积。 比如字符串”USACO” = 21 * 19 * 1 * 3 * 15 = 17955. 计算S1和S2对应的值,并且对47取模。如果取模后,计算得到两个数字相等,则输出”GO”, 否则输出 “STAY”。
题解:
usaco的第一题,根据题目的描述翻译成代码即可。
代码:
/*ID: zachery1PROG: rideLANG: C++*/#include <iostream>#include <fstream>#include <string>#define cin fin #define cout foutusing namespace std;ifstream fin("ride.in");ofstream fout("ride.out");string group, comet;long long g, c;int main() { ios::sync_with_stdio(false); g = c = 1; cin >> group >> comet; for (int i = 0; i < group.length(); i++) { g *= (group[i] - 'A' + 1); g %= 47; } for (int i = 0; i < comet.length(); i++) { c *= (comet[i] - 'A' + 1); c %= 47; } if (g == c) cout << "GO" << endl; else cout << "STAY" << endl; return 0;}
阅读全文
0 0
- USACO-Section1.1 Your Ride Is Here [模拟]
- USACO-Section1.1 Your Ride Is Here [模拟]
- USACO-Section1.1 Your Ride Is Here
- USACO-Section1.1 Your Ride Is Here
- USACO-Section1.1 Your Ride Is Here
- USACO Section1.1 Your Ride Is Here
- [USACO] Section1.1 Your Ride Is Here[字符串处理]
- [USACO] Section1.1 Your Ride Is Here[字符串处理]
- USCAO-Section1.1 Your Ride Is Here
- Your Ride Is Here-section1.1
- Section1.1-Your Ride Is Here
- USACO之Section1.1.1 Your Ride Is Here
- USACO 1.1.1 Your Ride Is Here
- [USACO 1.1.1] Your Ride Is Here
- USACO 1.1.1 Your Ride Is Here
- USACO 1.1.1 Your Ride Is Here
- USACO 1.1.1 Your Ride Is Here
- USACO 1.1.1 Your Ride Is Here
- CreateControl
- C++实验6
- C++作业六
- BZOJ4300 绝世好题
- 事务+事务特性+提交事务+回滚事务+保存点
- USACO-Section1.1 Your Ride Is Here [模拟]
- HDU 1080 Human Gene Functions(LCS变形)
- Android图片加载神器之Fresco,基于各种使用场景的讲解
- LeetCode练习_20170519
- 菜鸟教你配置mac下的java环境变量
- OpenGL:GLUT库字体设置API
- TCP/IP协议中的端口号
- 善良的老师 (优先队列)
- 关于caffe的序列 :用Caffe提取深度特征