結果

問題 No.3362 積分!!!
ユーザー yuunegi
提出日時 2026-11-13 11:42:48
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 899 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,321 ms
コンパイル使用メモリ 337,096 KB
実行使用メモリ 9,876 KB
最終ジャッジ日時 2026-11-13 11:42:54
合計ジャッジ時間 5,125 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 13 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
struct R{
    //de>0
    long long nu,de;
    bool operator<(const R& other) const {
        return (__int128)nu*other.de<(__int128)de*other.nu;
    }
    bool operator==(const R& other) const {
        return (__int128)nu*other.de==(__int128)de*other.nu;
    }
    R operator+(const R& other) const {
        return {nu*other.de+de*other.nu,de*other.de};
    }
    
};
int main(void){
    int n;
    long long a,b;
    cin>>n>>a>>b;
    R ans={0,1};
    for(int i=0;i<=n;i++){
        long long k;
        cin>>k;
        long long ta=1,tb=1;
        for(int j=0;j<=i;j++){
            ta*=a;
            tb*=b;
        }
        ans=ans+(R){k*(tb-ta),i+1};
    }
    if(ans.nu==0){
        cout<<0<<endl;
    }else if(ans.nu<0){
        cout<<-((abs(ans.nu)+ans.de-1)/ans.de)<<endl;
    }else{
        cout<<ans.nu/ans.de<<endl;
    }
    return 0;
}
0