結果

問題 No.1620 Substring Sum
ユーザー Noela3141592
提出日時 2021-09-19 17:02:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,193 bytes
コンパイル時間 1,530 ms
コンパイル使用メモリ 166,612 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-01 20:28:36
合計ジャッジ時間 2,923 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
// using mint = modint1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i=1;i<=(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using ll = long long;
typedef pair<int, int> P;
#define EPS (1e-12)
const int MOD=998244353;
// const int vx[]={0,1,0,-1},vy[]={1,0,-1,0};
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return a*b/gcd(a,b);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//a^t(mod m)  O(log t)
ll mpow(ll a,ll t,ll m){
    ll rec=1;
    while(t>0){
        if(t&1){
            rec=rec*a%m;
        }
        a=a*a%m;
        t>>=1;
    }
    return rec;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    ll ans=0;
    rep(i,s.size()){
        ll now=s[i]-'0';
        ans=ans*10+mpow(2,i,MOD)*now+ans;
        ans%=MOD;
        // cout<<ans<<'\n';
    }
    cout<<ans<<endl;
}
0