結果
| 問題 |
No.1501 酔歩
|
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2021-05-08 00:08:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 839 bytes |
| コンパイル時間 | 1,867 ms |
| コンパイル使用メモリ | 197,128 KB |
| 最終ジャッジ日時 | 2025-01-21 09:00:46 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 RE * 28 |
ソースコード
#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);
p /= g;
q /= g;
assert(q < 1000000007);
if (p == 0)
{
cout << 0 << endl;
}
else
{
cout << p << '/' << q << endl;
}
return 0;
}
trineutron