結果

問題 No.1343 Dividing Digit
ユーザー monnu
提出日時 2021-01-27 20:15:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 1,689 ms
コンパイル使用メモリ 169,800 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-24 21:58:32
合計ジャッジ時間 3,766 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
using Graph=vector<vector<pair<int,int>>>;

int main(){
  int N;
  ll K;
  cin>>N>>K;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }

  ll sum=0;
  for(int i=0;i<N;i++){
    sum+=A[i];
  }
  ll ans=0;
  ll res=1;
  for(int i=N-1;i>=0;i--){
    ans+=A[i]*res;
    ans%=sum;
    res=res*K%sum;
  }
  cout<<ans<<endl;
}
0