結果

問題 No.3362 積分!!!
コンテスト
ユーザー noya2
提出日時 2025-11-10 00:51:02
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 894 bytes
コンパイル時間 3,044 ms
コンパイル使用メモリ 279,748 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-11-17 20:44:15
合計ジャッジ時間 4,018 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4 WA * 2
other AC * 5 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = __int128_t;

ll input(){
    string s; cin >> s;
    ll x = 0;
    for (auto c : s){
        x *= 10;
        x += ll(c - '0');
    }
    return x;
}

void output(ll x){
    if (x == 0){
        cout << 0 << endl;
        return ;
    }
    string s = "";
    while (x){
        s += char(x % 10 + '0');
        x /= 10;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
}

int main(){
    int n; cin >> n;
    ll a = input(), b = input();
    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;
    for (int i = 0; i <= n; i++){
        ap *= a;
        bp *= b;
        ll k = input();
        sum += k * (bp - ap) * (iv / (i + 1));
    }
    ll ans = sum / iv;
    if (sum % iv != 0 && sum < 0){
        ans++;
    }
    output(ans);
}
0