結果

問題 No.1407 Kindness
ユーザー yuji9511yuji9511
提出日時 2021-02-27 00:33:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,069 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 198,288 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 14:55:00
合計ジャッジ時間 3,045 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void solve()':
main.cpp:46:49: warning: 'val' may be used uninitialized [-Wmaybe-uninitialized]
   46 |             nxt += start + v * (v-1) * i2 % MOD * val % MOD;
      |                            ~~~~~~~~~~~~~~~~~~~~~^~~~~
main.cpp:35:8: note: 'val' was declared here
   35 |     ll val, start;
      |        ^~~
main.cpp:46:26: warning: 'start' may be used uninitialized [-Wmaybe-uninitialized]
   46 |             nxt += start + v * (v-1) * i2 % MOD * val % MOD;
      |                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:35:13: note: 'start' was declared here
   35 |     ll val, start;
      |             ^~~~~

ソースコード

diff #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
ostream& operator<<(ostream& os, lpair& h){ os << "(" << h.first << ", " << h.second << ")"; return os;}
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
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; }
ll power(ll x, ll n, ll m = MOD){
    if(n == 0) return 1LL;
    ll res = power(x * x % m, n/2, m);
    if(n % 2 == 1) (res *= x) %= m;
    return res;
}

void solve(){
    ll N;
    cin >> N;
    string S = to_string(N);
    ll M = S.size();
    ll ans = 1;
    ll cur = 1;
    ll idx = 1;
    ll val, start;
    ll i2 = power(2,MOD-2);
    rrep(i,M-1,0){
        ll v = S[i] - '0';
        if(i == M-1){
            ans = v * (v+1) / 2;
            cur = 0;
            val = 45;
            start = 45;
        }else{
            ll nxt = v * (ans - cur + MOD) % MOD;
            nxt += start + v * (v-1) * i2 % MOD * val % MOD;
            nxt %= MOD;
            start += power(45, idx);
            start %= MOD;
            cur += power(45, idx-1);
            cur %= MOD;
            ans = nxt;
            val *= 45;
            val %= MOD;
        
        }
        idx++;
        // print(ans);
    }
    print(ans);
    // ll sum = 0;
    // rep(i,1,N+1){
    //     ll v = 1;
    //     ll n = i;
    //     while(n > 0){
    //         v *= n % 10;
    //         n /= 10;
    //     }
    //     sum += v;
    //     if(i == N) print(i,v,sum);
    // }
    

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0