結果

問題 No.1620 Substring Sum
ユーザー monnumonnu
提出日時 2021-07-23 07:13:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 3,869 ms
コンパイル使用メモリ 227,124 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 04:34:00
合計ジャッジ時間 5,656 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 46 ms
4,380 KB
testcase_05 AC 46 ms
4,380 KB
testcase_06 AC 47 ms
4,380 KB
testcase_07 AC 45 ms
4,380 KB
testcase_08 AC 46 ms
4,380 KB
testcase_09 AC 44 ms
4,380 KB
testcase_10 AC 46 ms
4,376 KB
testcase_11 AC 45 ms
4,380 KB
testcase_12 AC 15 ms
4,376 KB
testcase_13 AC 41 ms
4,376 KB
testcase_14 AC 43 ms
4,376 KB
testcase_15 AC 37 ms
4,376 KB
testcase_16 AC 27 ms
4,380 KB
testcase_17 AC 37 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 46 ms
4,380 KB
testcase_21 AC 45 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ll modpow(ll a,ll n){
  a%=MOD;
  ll ret=1;
  while(n>0){
    if((n&1)==1){
      ret=ret*a%MOD;
    }
    n>>=1;
    a=a*a%MOD;
  }
  return ret;
}

int main(){
  string S;
  cin>>S;
  int N=S.size();
  ll ans=0;
  for(int i=0;i<N;i++){
    ll x=(ll)(S[i]-'0');
    x=x*modpow(11,N-1-i)%MOD;
    x=x*modpow(2,i)%MOD;
    ans+=x;
    ans%=MOD;
  }
  cout<<ans<<endl;
}
0