結果

問題 No.840 ほむほむほむら
ユーザー tempura_pptempura_pp
提出日時 2019-03-26 01:34:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,021 bytes
コンパイル時間 816 ms
コンパイル使用メモリ 100,468 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-18 11:58:35
合計ジャッジ時間 3,983 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 WA -
testcase_23 RE -
testcase_24 RE -
testcase_25 WA -
testcase_26 WA -
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,k;
    cin>>n>>k;
    assert(n<20);
    int mask=pow(3,n);
    int ans=0;
    rep(i,mask){
        vector<int> v(n);
        int cur=i;
        rep(j,n){
            v.push_back(cur%3);
            cur/=3;
        }
        vector<int> dp(3);
        dp[0]=1;
        rep(j,n){
            if(v[i]==0)dp[0]++;
            if(v[i]==1)dp[1]+=dp[0];
            if(v[i]==2)dp[2]+=dp[1];
        }
        if(dp[2]%k==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}
0