結果

問題 No.3362 積分!!!
コンテスト
ユーザー shingo0909
提出日時 2025-11-17 21:16:53
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 556 bytes
コンパイル時間 3,122 ms
コンパイル使用メモリ 276,304 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-11-17 21:17:03
合計ジャッジ時間 3,995 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 8 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <cstdlib>
#include <math.h>
using namespace std;

using ll = long long;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll A=a;
    ll B=b;
    __int128_t d=1;
    for(int i=1;i<=n;i++)d*=i;
    __int128_t ans=0;
    for(int i=1;i<=n+1;i++){
        ll k;
        cin >> k;
        __int128_t x=__int128_t(k)*d/i;
        ans-=x*A;
        ans+=x*B;
        A*=a;
        B*=b;
    }
    if(ans<0 && ans%d!=0){
        cout << ll(ans/d)-1 << endl;
    }else{
        cout << ll(ans/d) << endl;
    }
    return 0;
}
0