結果

問題 No.2461 一点張り
ユーザー LynkcatLynkcat
提出日時 2023-09-08 21:24:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 2,818 ms
コンパイル使用メモリ 165,292 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 21:24:08
合計ジャッジ時間 2,155 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) (int)((x).size())
#define int ll
//#define N
using namespace std;

inline double quickPower(double x,ll y)
{
	double res=1;
	while (y)
	{
		if (y&1) res=res*x;
		x=x*x;
		y>>=1;
	}
	return res;
}
void BellaKira()
{
	double p;
	int n;
	cin>>p>>n;
	double ans=0;
	for (int i=1;i<=n;i++)
	{
		ans+=p*quickPower(1.0-p,i-1)*i;
	}
	ans+=quickPower(1.0-p,n)*n;
	cout<<fixed<<setprecision(10)<<ans<<'\n';
}
signed main()
{
	IOS;
	cin.tie(0);
	int T=1;
	cin>>T;
	while (T--)
	{
		BellaKira();
	}
}
0