結果
| 問題 |
No.2461 一点張り
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-08 23:20:41 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 4,731 bytes |
| コンパイル時間 | 3,936 ms |
| コンパイル使用メモリ | 266,628 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 16:44:35 |
| 合計ジャッジ時間 | 4,500 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 |
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// #include <atcoder/segtree>
// #include <atcoder/dsu>
// #include <atcoder/string>
// using namespace atcoder;
// #include <atcoder/modint>
// using mint = atcoder::modint1000000007;
// using mint = atcoder::modint998244353;
// #include <boost/multiprecision/cpp_int.hpp>
// using Bint = boost::multiprecision::cpp_int;
// #include <boost/multiprecision/cpp_dec_float.hpp>
// using Real = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1024>>;
// #include <boost/rational.hpp>
// using Rat = boost::rational<Bint>;
typedef long long ll;
const ll INF = 1e18;
// interactive
#define endl "\n"
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define llacumulate(v) accumulate(all(v), 0LL)
#define sz(x) (ll)(x).size()
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define pc __builtin_popcountll
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
using vi = vector<int>;
using vd = vector<double>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vp = vector<pair<ll, ll>>;
using vpc = vector<pair<char, ll>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
void yn(bool b) { cout << (b ? "Yes" : "No") << endl; }
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
struct Fast
{
Fast()
{
std::cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
} fast;
template <typename T>
bool chmax(T &a, const T &b)
{
if (a < b)
{
a = b;
return true;
}
return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
if (a > b)
{
a = b;
return true;
}
return false;
}
vector<pair<char, ll>> run_length(const string &str)
{
ll n = str.size();
vector<pair<char, ll>> res;
for (ll l = 0; l < n;)
{
ll r = l + 1;
while (r < n && str[l] == str[r])
++r;
res.push_back({str[l], r - l});
l = r;
}
return res;
}
template <typename T, typename S>
int get_nearest(const vector<T> &v, const S &a)
{
int x = lower_bound(all(v), a) - v.begin(), n = v.size();
if (x == 0)
return 0;
if (x == n)
return n - 1;
if (abs(v[x] - a) < abs(v[x - 1] - a))
return x;
else
return x - 1;
}
template <typename T>
vector<pair<ll, ll>> prime_factorize(T n)
{
vector<pair<ll, ll>> res;
for (ll i = 2; i * i <= n; ++i)
{
if (n % i != 0)
continue;
ll cnt = 0;
while (n % i == 0)
{
n /= i;
cnt++;
}
res.emplace_back(i, cnt);
}
if (n != 1)
res.emplace_back(n, 1);
return res;
}
void print() { cout << endl; }
template <typename T>
inline void print(const T &x) { cout << x << endl; }
template <class T, class... Ts>
void print(const T &a, const Ts &...b)
{
cout << a;
(cout << ... << (cout << ' ', b));
cout << endl;
}
template <typename T>
inline void print(const vector<T> &v)
{
rep(i, v.size())
{
if (i != (ll)v.size() - 1)
cout << v[i] << " ";
else
cout << v[i] << endl;
}
}
template <typename T>
inline void print(const vector<vector<T>> &v)
{
for (auto &&p : v)
print(p);
}
template <typename T, typename S>
inline void print(const pair<T, S> &p)
{
cout << p.first << " " << p.second << endl;
}
template <typename T, typename S>
inline void print(const vector<pair<T, S>> &v)
{
for (auto &&p : v)
print(p);
}
#ifdef LOCAL
#include <library/debug_print.hpp>
#define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (static_cast<void>(0))
#endif
int main()
{
ll t;
cin >> t;
rep(i, t)
{
double p;
ll k;
cin >> p >> k;
double ans = 0, now = 1;
rep(j, 1, k + 1)
{
if (j == k)
ans += now * j;
else
ans += now * p * j;
now = now - now * p;
}
print(ans);
}
}