結果
| 問題 |
No.58 イカサマなサイコロ
|
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-03-16 04:03:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,574 bytes |
| コンパイル時間 | 438 ms |
| コンパイル使用メモリ | 55,288 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 23:04:03 |
| 合計ジャッジ時間 | 1,414 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%d %d", &N, &K);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <iostream>
inline int expt(int a, int n){
int res = 1;
while(n > 0){
if(n & 1){res *= a;}
n >>= 1;
a *= a;
}
return res;
}
int count[61], count2[61];
double answer[11] = {0.474091,
0.552721,
0.630847,
0.702700,
0.763795,
0.812275,
0.849078,
0.876840,
0.898383,
0.915844,
0.930714};
int main(){
int N, K;
scanf("%d %d", &N, &K);
if(N == 10){printf("%.6f\n", answer[K]); return 0;}
int all = expt(6, N);
for(int i=0;i<all;i++){
int sum = 0, x = i;
for(int j=0;j<N-K;j++){
// printf("%d ", x % 6 + 1);
sum += x % 6 + 1;
x /= 6;
}
for(int j=0;j<K;j++){
// printf("%d ", x % 6 / 2 + 4);
sum += x % 6 / 2 + 4;
}
// puts("");
count[sum]++;
}
// puts(std::string(40, '-').c_str());
for(int i=0;i<all;i++){
int sum = 0, x = i;
for(int j=0;j<N;j++){
// printf("%d ", x % 6 + 1);
sum += x % 6 + 1;
x /= 6;
}
// puts("");
count2[sum]++;
}
for(int i=1;i<=60;i++){
count2[i] += count2[i-1];
}
double res = 0.0;
for(int i=1;i<=60;i++){
res += 1. * count[i] * count2[i-1];
}
res /= 1. * all * all;
printf("%.6f\n", res);
}
tottoripaper