結果
問題 | No.1343 Dividing Digit |
ユーザー |
![]() |
提出日時 | 2022-09-23 22:44:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 361 bytes |
コンパイル時間 | 1,930 ms |
コンパイル使用メモリ | 194,628 KB |
最終ジャッジ日時 | 2025-02-07 14:08:18 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int N,K; cin>>N>>K; vector<int> A(N); for(int i=0;i<N;i++) cin>>A[i]; int sum = 0; for(int i=0;i<N;i++) sum += A[i]; int now = 1; int ans = 0; for(int i=N-1;i>=0;i--){ ans += (now*A[i])%sum; now *= K; now %= sum; } cout<<ans%sum<<endl; }