結果

問題 No.1343 Dividing Digit
ユーザー ytftytft
提出日時 2021-06-08 17:59:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 5,759 ms
コンパイル使用メモリ 407,528 KB
実行使用メモリ 6,284 KB
最終ジャッジ日時 2023-08-17 21:01:21
合計ジャッジ時間 7,342 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 35 ms
6,128 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 7 ms
4,376 KB
testcase_07 AC 15 ms
4,380 KB
testcase_08 AC 29 ms
5,688 KB
testcase_09 AC 32 ms
5,776 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 13 ms
4,380 KB
testcase_12 AC 26 ms
5,416 KB
testcase_13 AC 24 ms
5,048 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 13 ms
4,376 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 AC 32 ms
5,752 KB
testcase_18 AC 33 ms
5,800 KB
testcase_19 AC 23 ms
5,212 KB
testcase_20 AC 17 ms
4,384 KB
testcase_21 AC 29 ms
5,708 KB
testcase_22 AC 30 ms
5,752 KB
testcase_23 AC 36 ms
6,072 KB
testcase_24 AC 25 ms
6,284 KB
権限があれば一括ダウンロードができます

ソースコード

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