結果
| 問題 |
No.220 世界のなんとか2
|
| コンテスト | |
| ユーザー |
togatoga
|
| 提出日時 | 2015-08-18 23:46:25 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,427 bytes |
| コンパイル時間 | 1,124 ms |
| コンパイル使用メモリ | 158,964 KB |
| 実行使用メモリ | 16,824 KB |
| 最終ジャッジ日時 | 2024-07-18 10:16:35 |
| 合計ジャッジ時間 | 5,428 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 18 |
コンパイルメッセージ
main.cpp: In function ‘ll solve()’:
main.cpp:61:1: warning: no return statement in function returning non-void [-Wreturn-type]
61 | }
| ^
ソースコード
#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 100000007;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N;
ll dp[21][3][2][2];//pos, div, three, less
ll solve(){
memset(dp, 0, sizeof(dp));
dp[0][0][0][0] = 1;
for (int i = 0; i < N; i++){
for (int j = 0; j < 3; j++){
for (int k = 0; k < 2; k++){
for (int m = 0; m < 2; m++){//0 equal 1 determine less
int digit = (i == 0 ? 1 : 0);
if (dp[i][j][k][m] == 0)continue;
for (int l = 0; l <= 9; l++){
if (m == 0){
if (l > digit)continue;
if (l == digit){
dp[i + 1][(10 * j + l) % 3][k][0] += dp[i][j][k][m];
}else{
dp[i + 1][(10 * j + l) % 3][k][1] += dp[i][j][k][m];
}
}else{
if (l == 3){
dp[i + 1][(10 * j + l) % 3][1][m] += dp[i][j][k][m];
}else{
dp[i + 1][(10 * j + l) % 3][k][m] += dp[i][j][k][m];
}
}
}
}
}
}
}
ll res = 0;
for (int j = 0; j < 2; j++){
res += dp[N][0][1][j];
res += dp[N][1][1][j];
res += dp[N][2][1][j];
res += dp[N][0][0][j];
}
cout << res - 1<< endl;
}
int main(){
cin >> N;
N++;
solve();
}
togatoga