結果
問題 | No.212 素数サイコロと合成数サイコロ (2) |
ユーザー |
![]() |
提出日時 | 2015-05-22 22:24:11 |
言語 | C++11 (gcc 8.5.0) |
結果 |
AC
|
実行時間 | 281 ms / 5,000 ms |
コード長 | 1,376 bytes |
コンパイル時間 | 1,053 ms |
使用メモリ | 3,764 KB |
最終ジャッジ日時 | 2023-02-08 18:07:47 |
合計ジャッジ時間 | 2,306 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
3,584 KB |
testcase_01 | AC | 2 ms
3,700 KB |
testcase_02 | AC | 2 ms
3,712 KB |
testcase_03 | AC | 2 ms
3,584 KB |
testcase_04 | AC | 10 ms
3,736 KB |
testcase_05 | AC | 281 ms
3,620 KB |
testcase_06 | AC | 48 ms
3,764 KB |
testcase_07 | AC | 49 ms
3,692 KB |
testcase_08 | AC | 2 ms
3,580 KB |
testcase_09 | AC | 1 ms
3,584 KB |
ソースコード
// Template {{{ #include <bits/stdc++.h> #define REP(i,n) for(int i=0; i<(int)(n); ++i) using namespace std; typedef long long LL; #ifdef LOCAL #include "contest.h" #else #define dump(x) #endif class range { struct Iterator { int val, inc; int operator*() {return val;} bool operator!=(Iterator& rhs) {return val < rhs.val;} void operator++() {val += inc;} }; Iterator i, n; public: range(int e) : i({0, 1}), n({e, 1}) {} range(int b, int e) : i({b, 1}), n({e, 1}) {} range(int b, int e, int inc) : i({b, inc}), n({e, inc}) {} Iterator& begin() {return i;} Iterator& end() {return n;} }; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; inline bool valid(int x, int w) { return 0 <= x && x < w; } void iostream_init() { ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(12); } //}}} double sum; double cnt; int a[] = {2,3,5,7,11,13}; int b[] = {4,6,8,9,10,12}; void dfs(int P, int C, double A) { if(P > 0) { REP(i, 6) dfs(P-1, C, A * a[i]); } else if(C > 0) { REP(i, 6) dfs(P, C-1, A * b[i]); } else { sum += A; cnt += 1; } } int main(){ iostream_init(); int P, C; cin >> P >> C; dfs(P, C, 1.0); cout << sum / cnt << endl; return 0; } /* vim:set foldmethod=marker: */