NYOJ 1013 除法表达式
来源:互联网 发布:java小软件源代码 编辑:程序博客网 时间:2024/05/22 00:43
经典的除法表达式题目
参见《算法竞赛入门经典(第二版)》P310~311
#include <iostream>#include <cstdio>#include <algorithm>#include <string>#include <sstream>using namespace std;const int MAXK = 10000;void solve(){ int a[MAXK]; string s; getline(cin, s); int k = 0; for (;;) { size_t found = s.find("/"); if (found == string::npos) { stringstream ss(s); ss >> a[k++]; break; } string substring = s.substr(0, found); //cout << substring << endl; stringstream ss(substring); ss >> a[k++]; s.erase(0, found + 1); } a[1] /= __gcd(a[1], a[0]); for (int i = 2; i < k; i++) { a[1] /= __gcd(a[1], a[i]); } if (a[1] == 1) puts("YES"); else puts("NO");}int main(){ //freopen("in.txt", "r", stdin); int t; scanf("%d\n", &t); while (t--) { solve(); }}
0 0
- NYOJ 1013 除法表达式
- NYOJ 题目1013 除法表达式(数学)
- 除法表达式
- 除法表达式
- 除法表达式
- 除法表达式
- tzc1537 除法表达式
- 数论之除法表达式
- 除法表达式问题
- nyoj1013 除法表达式
- 【数论】除法表达式
- 除法表达式-最大公约数
- COGS 2060 除法表达式
- COGS 2060. 除法表达式
- NYOJ_1013除法表达式
- TZC 1537 除法表达式 gcd
- el表达式除法取整
- cogs2060 除法表达式【解法一】
- 文章标题
- 路径问题系列之HDU1312 Red and Black(DFS)
- Meta http-equiv属性详解(转)
- react学习
- 欢迎使用CSDN-markdown编辑器
- NYOJ 1013 除法表达式
- hdu 2037贪心(选择不相交区间)
- Android(三)创建第一个android项目
- create synonym cimmgr.table_B for cimmgr.table_A; alter table cimmgr.table_a rename to table_c;
- MiniGUI输入法模块mGi软键盘使用实例
- 使用sh -x调试shell脚本
- hbase源码分析HTable ->getScanner(final Scan scan)源码分析
- iOS-数据存储之FMDB
- webGL第四课