結果
問題 |
No.1501 酔歩
|
ユーザー |
|
提出日時 | 2021-05-08 13:27:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 800 bytes |
コンパイル時間 | 800 ms |
コンパイル使用メモリ | 73,096 KB |
最終ジャッジ日時 | 2025-01-21 09:16:33 |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 53 |
ソースコード
#include <iostream> #include <numeric> #include <vector> using namespace std; using lint = long long; constexpr lint G = 6350400; // LCM(1,2,...,10)^2 void solve() { int n, k; cin >> n >> k; --k; if (n == 1) { cout << "1/1\n"; return; } if (k == 0) { cout << "0\n"; return; } vector<lint> xs(n); for (auto& x : xs) cin >> x; lint num = 0, dom = 0; for (int i = 1; i <= k; ++i) { num += G / xs[i] / xs[i - 1]; } for (int i = 1; i < n; ++i) { dom += G / xs[i] / xs[i - 1]; } { auto g = gcd(num, dom); num /= g, dom /= g; } cout << num << "/" << dom << "\n"; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }