結果
問題 | No.425 ジャンケンの必勝法 |
ユーザー |
|
提出日時 | 2016-09-23 00:05:43 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 870 bytes |
コンパイル時間 | 330 ms |
コンパイル使用メモリ | 24,448 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-17 15:15:32 |
合計ジャッジ時間 | 1,264 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 2 |
other | AC * 4 WA * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:35:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | scanf("%f %f", &p, &q); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include "stdio.h"float p,q;float ans;void sum(int fig,float now, int pre,float con) {if (fig > 20)return;if (pre== 1) {if (now - q > 0) {sum(fig + 1, now - q, 1, con/2.0*(now-q));sum(fig + 1, now-q, 0, con / 3.0*(1.0 - now + q));ans += con*((now - q) / 2.0 + (1.0 - now + q) / 3.0);}else {sum(fig + 1, 0.0, 0, con / 3.0);ans += con / 3.0;}}else {if (now + q < 1) {sum(fig + 1, now + q, 1, con / 2.0 * (now + q));sum(fig + 1, now + q, 0, con / 3.0 * (1.0 - now - q));ans += con*((now + q) / 2.0 + (1 - now - q) / 3.0);}else {sum(fig + 1, 1.0, 1, con / 2.0);ans += con / 2.0;}}}int main() {scanf("%f %f", &p, &q);p = p / 100;q = q / 100;ans += 1.0 / 3.0;ans += p / 6.0;ans += (1 - p) / 9.0;sum(1, p, 1, p / 6.0);sum(1, p, 0, (1-p)/9.0);printf("%f\n", ans);return 0;}