結果

問題 No.2461 一点張り
ユーザー qi_yaoqi_yao
提出日時 2023-09-08 22:30:02
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 879 bytes
コンパイル時間 4,915 ms
コンパイル使用メモリ 131,804 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 22:30:14
合計ジャッジ時間 4,010 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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