結果
| 問題 |
No.2461 一点張り
|
| コンテスト | |
| ユーザー |
hiro71687k
|
| 提出日時 | 2023-09-08 21:26:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 2,000 ms |
| コード長 | 699 bytes |
| コンパイル時間 | 4,113 ms |
| コンパイル使用メモリ | 252,108 KB |
| 最終ジャッジ日時 | 2025-02-16 19:33:41 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=1000000007;
ll inf=10090000000000000;
int main(){
ll t;
cin >> t;
for (ll o = 0; o < t; o++)
{
ld p;
cin >> p;
ll k;
cin >> k;
if (k==1)
{
cout << 1 << endl;
continue;
}
vector<ld>x(k+1,0);
x[1]=p;
ld now=p;
for (ll i = 2; i < k; i++)
{
x[i]=p*(1.0-now);
now+=x[i];
}
ld ans=0;
for (ll i = 1; i < k; i++)
{
ans+=(ld)i*x[i];
}
ans+=k*(1.0-now);
cout << setprecision(100) << ans << endl;
}
}
hiro71687k