結果

問題 No.1343 Dividing Digit
ユーザー ytft
提出日時 2021-06-08 17:59:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 4,843 ms
コンパイル使用メモリ 387,452 KB
実行使用メモリ 6,816 KB
最終ジャッジ日時 2024-11-26 21:16:33
合計ジャッジ時間 6,107 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mp;
int main(){
    int N,K;
    cin>>N>>K;
    vector<mp> A(N);
    mp s=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        s+=A[i];
    }
    mp ans=0;
    mp temp=1;
    for(int i=N-1;i>=0;i--){
        ans=(ans+temp*A[i])%s;
        temp=(temp*K)%s;
    }
    cout<<ans<<endl;
}
0