結果
問題 |
No.741 AscNumber(Easy)
|
ユーザー |
![]() |
提出日時 | 2021-07-13 03:16:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 522 ms / 2,000 ms |
コード長 | 695 bytes |
コンパイル時間 | 1,931 ms |
コンパイル使用メモリ | 193,804 KB |
最終ジャッジ日時 | 2025-01-23 00:53:32 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 55 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; ll dp[1000100][2][10]; const int MOD=1e9+7; int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; string N="1"; rep(i,n) N+='0'; dp[0][0][0]=1; rep(i,n+1){ int Ni=N[i]-'0'; rep(j,2) rep(k,10) rep(x,10){ int j2=j,k2=k; if(x<k2) continue; k2=x; if(!j2 && (x>Ni)) continue; if(x<Ni) j2=1; dp[i+1][j2][k2]=(dp[i+1][j2][k2]+dp[i][j][k])%MOD; } } ll ans=0; rep(i,10) ans=(ans+dp[n+1][1][i])%MOD; cout<<ans<<endl; return 0; }