結果
問題 |
No.813 ユキちゃんの冒険
|
ユーザー |
![]() |
提出日時 | 2020-12-08 16:38:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 765 bytes |
コンパイル時間 | 2,708 ms |
コンパイル使用メモリ | 195,084 KB |
最終ジャッジ日時 | 2025-01-16 19:46:11 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000 using P = pair<long double,long double>; P merge(P a,P b){ long double temp = a.first*b.first; temp = 1.0-temp; temp = 1.0/temp; P ret; ret.first = a.first; ret.first += temp * a.second * a.second * b.first; ret.second = temp * a.second * b.second; return ret; } int main(){ int N; cin>>N; long double p,q; cin>>p>>q; if(p==1.0){ cout<<p<<endl; return 0; } vector<P> x(12); rep(i,12){ if(i==0)x[i] = make_pair(p,q); else x[i] = merge(x[i-1],x[i-1]); } P ans = x[0]; N--; rep(i,12){ if(N&1){ ans = merge(ans,x[i]); } N/=2; } cout<<fixed<<setprecision(10)<<ans.first<<endl; return 0; }