結果

問題 No.280 歯車の問題(1)
ユーザー face4face4
提出日時 2018-05-11 21:27:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 615 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 63,920 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 04:01:34
合計ジャッジ時間 2,854 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<iostream>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){
return b==0 ? a : gcd(b, a%b);
}
int main(){
int n;
ll mother, child;
cin >> n >> mother >> child;
ll g = gcd(mother,child);
ll first = mother;
ll second = child;
mother /= g;
child /= g;
for(int i = 2; i < n; i++){
first = second;
cin >> second;
g = gcd(first, second);
mother *= first/g;
child *= second/g;
g = gcd(mother,child);
mother /= g;
child /= g;
}
cout << child << "/" << mother << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0