結果
問題 | No.1407 Kindness |
ユーザー |
![]() |
提出日時 | 2021-02-26 21:44:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 1,263 bytes |
コンパイル時間 | 1,510 ms |
コンパイル使用メモリ | 168,172 KB |
実行使用メモリ | 19,584 KB |
最終ジャッジ日時 | 2024-10-02 14:20:02 |
合計ジャッジ時間 | 3,552 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long int ll;typedef pair<ll,ll> P;typedef vector<ll> VI;typedef vector<VI> VVI;#define REP(i,n) for(ll i=0;i<(n);i++)#define ALL(v) v.begin(),v.end()constexpr ll MOD=1000000007;constexpr ll INF=1e18;int main(){string s; cin >> s;int n=s.size();ll dp[2][101010][10]={0};REP(i,n-1)dp[1][i+1][0]=1;dp[0][0][0]=1;REP(i,n){REP(k,10){if(k<s[i]-'0'){REP(j,10){dp[1][i+1][k]+=k*dp[1][i][j]%MOD;dp[1][i+1][k]+=k*dp[0][i][j]%MOD;dp[1][i+1][k]%=MOD;}}else if(k==s[i]-'0'){REP(j,10){dp[0][i+1][k]+=k*dp[0][i][j]%MOD;dp[0][i+1][k]%=MOD;dp[1][i+1][k]+=k*dp[1][i][j]%MOD;dp[1][i+1][k]%=MOD;}}else{REP(j,10){dp[1][i+1][k]+=k*dp[1][i][j]%MOD;dp[1][i+1][k]%=MOD;}}}}ll ans=0;REP(i,10)ans+=dp[1][n][i];ans+=dp[0][n][s[n-1]-'0'];cout << ans%MOD << endl;}