NC52868. Strange Optimization
描述
输入描述
The input contains zero or more test cases and is terminated by end-of-file.
Each test case contains two integers n, m.
*
* The number of tests cases does not exceed .
输出描述
For each case, output a fraction p/q which denotes the result.
示例1
输入:
1 1 1 2
输出:
1/2 1/4
C++14(g++5.4) 解法, 执行用时: 36ms, 内存消耗: 608K, 提交时间: 2019-10-04 23:20:14
#include<bits/stdc++.h> using namespace std; int main(){ long long n,m; while(cin>>n>>m){ cout<<"1/"<<2*n/__gcd(n,m)*m<<endl; } }
C++11(clang++ 3.9) 解法, 执行用时: 34ms, 内存消耗: 600K, 提交时间: 2019-10-04 17:18:33
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,m; while(cin>>n>>m) cout<<"1/"<<2*n/__gcd(n,m)*m<<endl; }