結果

問題 No.813 ユキちゃんの冒険
ユーザー beetbeet
提出日時 2019-04-12 21:42:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 814 bytes
コンパイル時間 2,340 ms
コンパイル使用メモリ 207,572 KB
実行使用メモリ 502,152 KB
最終ジャッジ日時 2023-08-30 13:23:11
合計ジャッジ時間 5,971 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  using D = long double;
  D p,q;
  cin>>p>>q;

  const D EPS = 1e-10;
  using T = tuple<Int, Int, D>;
  queue<T> que;
  que.emplace(1,1,1.0);

  D ans=0;
  while(!que.empty()){
    Int v,d;D x;
    tie(v,d,x)=que.front();que.pop();
    if(x<EPS) continue;    
    if(v+d==0) ans+=x*q;
    if(0<v+d&&v+d<=n) que.emplace(v+d,d,x*q);
    if(v-d==0) ans+=x*p;
    if(0<v-d&&v-d<=n) que.emplace(v-d,-d,x*p);
  }
  
  cout<<ans<<endl;
  return 0;
}
0