結果
問題 | No.741 AscNumber(Easy) |
ユーザー |
![]() |
提出日時 | 2020-08-17 23:59:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 363 ms / 2,000 ms |
コード長 | 1,254 bytes |
コンパイル時間 | 1,021 ms |
コンパイル使用メモリ | 100,180 KB |
実行使用メモリ | 159,744 KB |
最終ジャッジ日時 | 2024-10-11 11:31:36 |
合計ジャッジ時間 | 7,246 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 55 |
ソースコード
#include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<string> #include<utility> #include<map> #include<set> #include<queue> #include<stack> #include<functional> #include<math.h> #include<random> #include <bitset> #include <cassert> #include <complex> using namespace std; #define N (1000000000+7) //#define N 998244353 #define INF 1e16 typedef long long ll; typedef pair<int,int> P; const int inf = 1e8; ll dp[1000100][2][10]; int main() { int n; cin>>n; dp[0][0][0]=1; for(int i=0;i<=n;i++){ int x = ((i==0)?1:0); for(int k=0;k<10;k++){ for(int l=k;l<10;l++){ if(l==x)dp[i+1][0][l] = (dp[i+1][0][l]+dp[i][0][k])%N; else{ dp[i+1][1][l] = (dp[i+1][1][l]+dp[i][0][k])%N; } } } for(int k=0;k<10;k++){ for(int l=k;l<10;l++){ if(l==x)dp[i+1][1][l] = (dp[i+1][1][l]+dp[i][1][k])%N; else{ dp[i+1][1][l] = (dp[i+1][1][l]+dp[i][1][k])%N; } } } } ll ans = 0; for(ll i=0;i<10;i++){ ans = (ans+dp[n][1][i])%N; ans = (ans+dp[n][0][i])%N; } cout<<ans<<endl; }