結果
問題 | No.1501 酔歩 |
ユーザー |
![]() |
提出日時 | 2021-05-07 22:11:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 831 bytes |
コンパイル時間 | 1,987 ms |
コンパイル使用メモリ | 196,916 KB |
最終ジャッジ日時 | 2025-01-21 08:18:39 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 53 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){int n, k;cin >> n >> k;assert(1 <= k and k <= n and n <= 100000);if (n == 1){cout << "1/1" << endl;return 0;}vector<int> a(n);for (int i = 0; i < n; i++){cin >> a.at(i);assert(1 <= a.at(i) and a.at(i) <= 10);}const int root = 2520 * 2520;vector<int> d(n - 1);for (int i = 0; i < n - 1; i++){d.at(i) = root / (a.at(i) * a.at(i + 1));}int64_t p = accumulate(d.begin(), d.begin() + k - 1, int64_t()), q = accumulate(d.begin(), d.end(), int64_t());int64_t g = gcd(p, q);assert(g != 0);p /= g;q /= g;if (p == 0){cout << 0 << endl;}else{cout << p << '/' << q << endl;}return 0;}