結果

問題 No.287 場合の数
ユーザー daleksprinter
提出日時 2019-03-19 19:02:22
言語 C++14
(gcc 8.2.0)
結果
AC  
実行時間 38 ms
コード長 2,652 Byte
コンパイル時間 1,347 ms
使用メモリ 1,528 KB
最終ジャッジ日時 2019-07-03 04:23:16

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
input.txt AC 25 ms
1,524 KB
sample1.txt AC 3 ms
1,524 KB
sample2.txt AC 3 ms
1,528 KB
sample3.txt AC 38 ms
1,528 KB
system_test1.txt AC 38 ms
1,524 KB
test1.txt AC 25 ms
1,524 KB
test2.txt AC 3 ms
1,524 KB
test3.txt AC 10 ms
1,524 KB
test4.txt AC 16 ms
1,520 KB
test5.txt AC 25 ms
1,520 KB
test6.txt AC 37 ms
1,524 KB
test7.txt AC 8 ms
1,524 KB
test8.txt AC 37 ms
1,524 KB
test9.txt AC 5 ms
1,524 KB
test10.txt AC 12 ms
1,528 KB
test11.txt AC 23 ms
1,524 KB
test12.txt AC 11 ms
1,528 KB
test13.txt AC 31 ms
1,524 KB
test14.txt AC 10 ms
1,528 KB
test15.txt AC 27 ms
1,524 KB
test16.txt AC 14 ms
1,528 KB
test17.txt AC 25 ms
1,528 KB
test18.txt AC 24 ms
1,524 KB
test19.txt AC 20 ms
1,524 KB
test20.txt AC 12 ms
1,528 KB
テストケース一括ダウンロード

ソースコード

diff #
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int n;
void in(){
    cin >> n;
}

int dfs(int l, int r, int s){
    if(l == r) return 0 <= s && s <= n;

    int ans = 0;
    int len = r - l + 1;

    rep(i,max(0LL, s - n * (len / 2)), len / 2 * n + 1){
        int m = (l + r) / 2;
        ans += dfs(l, m, i) * dfs(m + 1, r, s - i);
    }

    return ans;

}


void solve(){
    
    print(dfs(0, 7, n * 6));


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}
0