結果

問題 No.425 ジャンケンの必勝法
ユーザー olpheolphe
提出日時 2016-09-23 00:05:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 24,576 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 20:01:29
合計ジャッジ時間 1,067 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 0 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |         ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
}
0