結果
問題 | No.220 世界のなんとか2 |
ユーザー |
|
提出日時 | 2017-12-08 12:03:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 947 bytes |
コンパイル時間 | 2,223 ms |
コンパイル使用メモリ | 193,252 KB |
最終ジャッジ日時 | 2025-01-05 04:57:35 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 1 |
ソースコード
#include <bits/stdc++.h>#define REP(i,a,b) for(int i=(a);i<(b);i++)#define RREP(i,a,b) for(int i=(a);i>=(b);i--)#define pq priority_queue#define P pair<int,int>#define P2 pair<int,P>#define P3 pair<int,P2>typedef long long ll; typedef long double ld;using namespace std;const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};const ll LINF=1e18;const ld PI=abs(acos(-1));ll a,dp[20][2][2][3]; //dp[i][j][k][l]:=i桁, kは3が付いているか, lは3による剰余string s="1";int main(){cin >> a;REP(i,0,a) s+='0';REP(i,0,20) REP(j,0,2) REP(k,0,2) REP(l,0,3) dp[i][j][k][l]=0;dp[0][0][0][0]=1;REP(i,0,s.size()){int D=s[i]-'0';REP(j,0,2){REP(k,0,2){REP(l,0,3){REP(d,0,(j?9:D)+1){dp[i+1][j|d<D][k|d==3][(l+d)%3]+=dp[i][j][k][l];}}}}}ll ans=0;REP(i,0,2) REP(j,0,2) REP(k,0,3) if(j==1 or k==0) ans+=dp[s.size()][i][j][k];cout << ans-1 << endl;return 0;}