結果

問題 No.2461 一点張り
ユーザー qi_yao
提出日時 2023-09-08 22:30:02
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 879 bytes
コンパイル時間 3,012 ms
コンパイル使用メモリ 162,916 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 15:41:47
合計ジャッジ時間 3,283 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

//洛门永存
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define LL long long
#define ULL unsigned long long
#define LD long double
#define PII pair<int, int>
//#define int long long
LL gcd(LL a,LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a,LL b) {return a / gcd(a, b) * b;}
//head

signed main()
{
	//0.7 + 2 * 0.3 * 0.7 + 3 * 0.3 * 0.3 * 0.7 + 4 * 0.3 * 0.3 * 0.3 * 0.7 + 5 * 0.3 * 0.3 * 0.3 * 0.3;
	int _; cin >> _;
	while (_ -- ){
		double p; int k; cin >> p >> k;
		
		double res = 0, overl = 1;
		for (int i = 1; i <= k; i ++ ){
			if (i == k){
				res += (i * overl);
			}
			else{
				res += (i * overl * p);
			}
			overl *= (1 - p);
		}
		cout << setprecision(15) << res << endl;
	}
}
0