結果
問題 | No.1407 Kindness |
ユーザー | yuji9511 |
提出日時 | 2021-02-27 00:33:34 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,069 bytes |
コンパイル時間 | 2,281 ms |
コンパイル使用メモリ | 203,004 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-02 16:41:09 |
合計ジャッジ時間 | 3,259 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | AC | 1 ms
6,816 KB |
testcase_07 | AC | 2 ms
6,820 KB |
testcase_08 | AC | 2 ms
6,816 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 1 ms
6,816 KB |
testcase_11 | AC | 2 ms
6,816 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:48:19: warning: 'start' may be used uninitialized [-Wmaybe-uninitialized] 48 | start += power(45, idx); | ~~~~~~^~~~~~~~~~~~~~~~~ main.cpp:35:13: note: 'start' was declared here 35 | ll val, start; | ^~~~~ main.cpp:53:17: warning: 'val' may be used uninitialized [-Wmaybe-uninitialized] 53 | val *= 45; | ~~~~^~~~~ main.cpp:35:8: note: 'val' was declared here 35 | ll val, start; | ^~~
ソースコード
/*** 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(); }