結果
| 問題 |
No.3362 積分!!!
|
| コンテスト | |
| ユーザー |
noya2
|
| 提出日時 | 2025-11-10 01:09:12 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,363 bytes |
| コンパイル時間 | 3,091 ms |
| コンパイル使用メモリ | 282,708 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-11-17 20:44:22 |
| 合計ジャッジ時間 | 3,903 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 14 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = __int128_t;
#include<atcoder/modint>
using mint = atcoder::modint998244353;
ll input(){
string s; cin >> s;
ll x = 0;
bool neg = false;
if (s[0] == '-'){
neg = true;
s = s.substr(1);
}
for (auto c : s){
x *= 10;
x += ll(c - '0');
}
if (neg) x = -x;
return x;
}
void output(ll x){
if (x == 0){
cout << 0 << endl;
return ;
}
string s = "";
bool neg = false;
if (x < 0){
neg = true;
x = -x;
}
while (x){
s += char(x % 10 + '0');
x /= 10;
}
reverse(s.begin(),s.end());
if (neg) cout << '-';
cout << s << endl;
}
int main(){
int n; cin >> n;
ll a = input(), b = input();
mint ma = a, mb = b;
ll iv = 1;
for (int i = 0; i <= n; i++){
iv *= (i + 1) / gcd((long long)iv, i + 1);
}
ll sum = 0;
ll ap = 1, bp = 1;
mint mans = 0;
for (int i = 0; i <= n; i++){
ap *= a;
bp *= b;
ll k = input();
sum += k * (bp - ap) * (iv / (i + 1));
mans += k * (mb.pow(i+1) - ma.pow(i+1)) * mint(i + 1).inv();
}
mint test = mint(sum) * mint(iv).inv();
assert(mans == test);
ll ans = sum / iv;
if (sum % iv != 0 && sum < 0){
ans--;
}
output(ans);
}
noya2