結果
| 問題 |
No.1407 Kindness
|
| コンテスト | |
| ユーザー |
Izayoi_R_sakura
|
| 提出日時 | 2020-11-29 20:54:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 672 bytes |
| コンパイル時間 | 1,004 ms |
| コンパイル使用メモリ | 74,472 KB |
| 最終ジャッジ日時 | 2025-01-16 10:16:08 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 36 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
using namespace std ;
using ll = long long ;
ll mod = 1e9+7 ;
int main(){
ios::sync_with_stdio(false) ;
cin.tie(nullptr) ;
string n ; cin >> n ;
int d = n.size() ;
vector<int> sum = {0,1,3,6,10,15,21,28,36,45} ;
vector<ll> pow45(d,1) ;
for(int i=1;i<d;i++) pow45[i] = pow45[i-1]*45%mod ;
ll ans = sum[n[0]-'0'-1]*pow45[d-1]%mod ;
ll mul = n[0]-'0' ;
for(int i=1;i<d;i++){
ans += pow45[d-i] ;
if(ans>=mod) ans -= mod ;
ans += sum[max(0,n[i]-'0'-1)]*pow45[d-i-1]%mod*mul%mod ;
if(ans>=mod) ans -= mod ;
mul = mul*(n[i]-'0')%mod ;
}
ans += mul ; if(ans>=mod) ans -= mod ;
cout << ans << endl ;
}
Izayoi_R_sakura