結果
問題 | No.425 ジャンケンの必勝法 |
ユーザー |
![]() |
提出日時 | 2016-09-23 00:15:11 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,822 ms / 2,000 ms |
コード長 | 759 bytes |
コンパイル時間 | 1,247 ms |
コンパイル使用メモリ | 160,428 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 13:59:58 |
合計ジャッジ時間 | 45,896 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h>using namespace std;int p;int q;long double dp[2][102];vector<double> v;int main(){cin >> p >> q;double ans = 1.0 / 3.0;dp[0][p] = 1.0 / 3.0;int siz = v.size();bool flag = false;double star = clock();while((clock()-star)/(double)(CLOCKS_PER_SEC)<1.8){for (int j = 0; j <=100; j++){if (1){//winlong double P = j;P /= 100.0;ans += dp[flag][j] * P*1.0 / 2.0;//tieint nex_j = max(j-q,0);dp[flag^true][nex_j] += dp[flag][j] * P*1.0 / 2.0;//nothingP = (1.0 - P);ans += dp[flag][j] * P*1.0 / 3.0;nex_j = min(j + q,100);dp[flag^true][nex_j] += dp[flag][j] * P*1.0 / 3.0;}dp[flag][j] = 0;}flag ^= true;}printf("%.16f\n", ans);return 0;}