結果
| 問題 |
No.220 世界のなんとか2
|
| コンテスト | |
| ユーザー |
tossy
|
| 提出日時 | 2017-01-01 17:42:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 984 bytes |
| コンパイル時間 | 708 ms |
| コンパイル使用メモリ | 90,888 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-16 04:58:57 |
| 合計ジャッジ時間 | 1,511 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second
#define INF 2147483600
#define long long long
long dp[21][2][3];
// [上から何桁][3を使った][mod3]
int main(){
int p;
cin>>p;
fill(dp[0][0], dp[20][0], 0);
dp[0][0][0]=1;
rep(i,p) rep(j,2) rep(k,3){
rep(l,10) dp[i+1][j | (l==3)][(k*10+l)%3] += dp[i][j][k];
}
long ans=0;
rep(i,3) ans += dp[p][1][i];
ans += dp[p][0][0];
cout << ans-1 << endl; // このままだと0を含む
return 0;
}
tossy