結果
| 問題 |
No.2461 一点張り
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-10 01:50:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 2,211 bytes |
| コンパイル時間 | 3,842 ms |
| コンパイル使用メモリ | 232,628 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-27 17:57:25 |
| 合計ジャッジ時間 | 4,598 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 |
ソースコード
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>
#include<atcoder/all>
#define rep(i,n)for(ll i=0;i<n;i++)
#define sor(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define prique priority_queue<int, vector<int>, greater<int> >
using ll = long long;
using ull = unsigned long long;
ll mod = 998244353;
ll modi = 499122177;
const int inf = 1000000000;
using namespace std;
using namespace atcoder;
vector<ll> topological_sort(vector<vector<ll>>& G, vector<ll>& indegree) {
ll n = G.size();
vector<ll> res;
priority_queue<ll, vector<ll>, greater<ll>> que;
for (ll i = 1; i < n; i++) if (indegree[i] == 0) que.push(i);
while (!que.empty()) {
ll ver = que.top();
que.pop();
res.push_back(ver);
for (int i : G[ver]) {
indegree[i]--;
if (indegree[i] == 0) que.push(i);
}
}
return res;
}
ll gcd(ll a, ll b) {
if (a > b)swap(a, b);
while (a > 0) {
b %= a;
if (a > b)swap(a, b);
if (a == b)break;
}
return b;
}
bool IsPrime(int num)
{
if (num < 2) return false;
else if (num == 2) return true;
else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
double sqrtNum = sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2)
{
if (num % i == 0)
{
// 素数ではない
return false;
}
}
// 素数である
return true;
}
bool ing(ll x, ll y, ll h, ll w) {
bool a = x < h && y < w;
bool b = x >= 0 && y >= 0;
return a && b;
}
void dfs(vector<ll>& vis, vector<vector<ll>>& G, ll x) {
vis[x] = 1;
for (ll i : G[x]) {
if (vis[i] == 0) {
dfs(vis, G, i);
}
}
}
int main() {
ll t;
cin >> t;
while (t--) {
ll k;
double p;
cin >> p >> k;
double ans = 0;
double j = 1;
for (ll i = 1; i < k; i++) {
double a = pow(1 - p, i - 1) * p;
j-= a;
ans += a * i;
}
ans += j * k;
cout <<fixed<< setprecision(10);
cout <<ans << endl;
}
}