結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,834 ms
6,816 KB
testcase_01 AC 195 ms
6,940 KB
testcase_02 AC 64 ms
6,944 KB
testcase_03 AC 8 ms
6,944 KB
testcase_04 AC 22 ms
6,940 KB
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 2 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
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<=16);
    int mask=1;
    rep(i,n)mask*=3;
    int ans=0;
    rep(i,mask){
        vector<int> v(n);
        int cur=i;
        rep(j,n){
            v[j]=cur%3;
            cur/=3;
        }
        vector<int> dp(3);
        rep(j,n){
            if(v[j]==0)dp[0]++;
            if(v[j]==1)dp[1]+=dp[0];
            if(v[j]==2)dp[2]+=dp[1];
        }
        if(dp[2]%k==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}
0