結果

問題 No.220 世界のなんとか2
ユーザー ttakanottakano
提出日時 2017-12-05 00:22:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 832 bytes
コンパイル時間 2,195 ms
コンパイル使用メモリ 144,432 KB
実行使用メモリ 5,272 KB
最終ジャッジ日時 2023-08-18 21:55:25
合計ジャッジ時間 3,772 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int p;
ll dp[30][2][2][3];

int main(){
  cin>>p;
  dp[0][0][0][0]=1;
  REP(i,p+1){
    REP(j,2){
      int lim;
      if(j==1)lim=9;
      else if(j==0&&i==0)lim=1;
      else lim=0;
      REP(k,2){
        REP(l,3){
          REP(m,lim+1){
            dp[i+1][j||m<lim][k||m==3][(l+m)%3]+=dp[i][j][k][l];
          }
        }
      }
    }
  }
  ll ans=0;
  REP(j,2)REP(k,2)REP(l,3){
    if(k==1||l==0){
      ans+=dp[p+1][j][k][l];
    }
  }
  print(ans);
}
0