結果
問題 | No.280 歯車の問題(1) |
ユーザー |
![]() |
提出日時 | 2015-09-24 21:23:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 446 bytes |
コンパイル時間 | 522 ms |
コンパイル使用メモリ | 60,520 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 09:04:24 |
合計ジャッジ時間 | 2,600 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
#include<iostream> #include<vector> int gcd(long long x, long long y) { while (true) { x = x % y; if (x == 0) return y; y = y % x; if (y == 0) return x; } } int main() { int gear_num; std::cin >> gear_num; std::vector<long long> v(gear_num); for (int i = 0; i < gear_num; i++) { std::cin >> v[i]; } long long g = gcd(v.front(), v.back()); std::cout << v.back() / g << "/" << v.front() / g << std::endl; return 0; }