結果
| 問題 |
No.301 サイコロで確率問題 (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-10-04 11:48:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 8,876 bytes |
| コンパイル時間 | 2,024 ms |
| コンパイル使用メモリ | 216,336 KB |
| 最終ジャッジ日時 | 2025-01-06 14:15:52 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
#define debugos cout
#define debug(v) {printf("L%d %s > ",__LINE__,#v);debugos<<(v)<<endl;}
#define debugv(v) {printf("L%d %s > ",__LINE__,#v);for(auto e:(v)){debugos<<e<<" ";}debugos<<endl;}
#define debuga(m,w) {printf("L%d %s > ",__LINE__,#m);for(int x=0;x<(w);x++){debugos<<(m)[x]<<" ";}debugos<<endl;}
#define debugaa(m,h,w) {printf("L%d %s >\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){debugos<<(m)[y][x]<<" ";}debugos<<endl;}}
#define ALL(v) (v).begin(),(v).end()
#define repeat(cnt,l) for(remove_reference<remove_const<decltype(l)>::type>::type cnt=0;(cnt)<(l);++(cnt))
#define rrepeat(cnt,l) for(auto cnt=(l)-1;0<=(cnt);--(cnt))
#define iterate(cnt,b,e) for(auto cnt=(b);(cnt)!=(e);++(cnt))
#define diterate(cnt,b,e) for(auto cnt=(b);(cnt)!=(e);--(cnt))
const ll MD = 1000000007ll; const long double PI = 3.1415926535897932384626433832795L;
inline void assert_call(bool assertion, function<void()> f) { if (!assertion) { cerr << "assertion fault:" << endl; f(); abort(); } }
template<typename T1, typename T2> inline ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << '(' << p.first << ':' << p.second << ')'; return o; }
template<typename Vec> inline ostream& _ostream_vecprint(ostream& os, const Vec& a) {
os << '['; for (const auto& e : a) os << ' ' << e << ' '; os << ']'; return os;
}
template<typename T> inline ostream& operator<<(ostream& o, const vector<T>& v) { return _ostream_vecprint(o, v); }
template<typename T, size_t S> inline ostream& operator<<(ostream& o, const array<T, S>& v) { return _ostream_vecprint(o, v); }
template<typename T> inline T& maxset(T& to, const T& val) { return to = max(to, val); }
template<typename T> inline T& minset(T& to, const T& val) { return to = min(to, val); }
void bye(string s, int code = 0) { cout << s << endl; exit(code); }
mt19937_64 randdev(8901016);
template<typename T> inline T rand(T l, T h) { return uniform_int_distribution<T>(l, h)(randdev); }
template<> inline double rand<double>(double l, double h) { return uniform_real_distribution<double>(l, h)(randdev); }
template<> inline float rand<float>(float l, float h) { return uniform_real_distribution<float>(l, h)(randdev); }
#if defined(_WIN32) || defined(_WIN64)
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#elif defined(__GNUC__)
#else
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#endif
namespace {
#define isvisiblechar(c) (0x21<=(c)&&(c)<=0x7E)
class MaiScanner {
public:
template<typename T> void input_integer(T& var) noexcept {
var = 0; T sign = 1;
int cc = getchar_unlocked();
for (; cc < '0' || '9' < cc; cc = getchar_unlocked())
if (cc == '-') sign = -1;
for (; '0' <= cc && cc <= '9'; cc = getchar_unlocked())
var = (var << 3) + (var << 1) + cc - '0';
var = var * sign;
}
inline int c() noexcept { return getchar_unlocked(); }
inline MaiScanner& operator>>(int& var) noexcept { input_integer<int>(var); return *this; }
inline MaiScanner& operator>>(long long& var) noexcept { input_integer<long long>(var); return *this; }
inline MaiScanner& operator>>(string& var) {
int cc = getchar_unlocked();
for (; !isvisiblechar(cc); cc = getchar_unlocked());
for (; isvisiblechar(cc); cc = getchar_unlocked())
var.push_back(cc);
return *this;
}
template<typename IT> void in(IT begin, IT end) { for (auto it = begin; it != end; ++it) *this >> *it; }
};
class MaiPrinter {
public:
template<typename T>
void output_integer(T var) noexcept {
if (var == 0) { putchar_unlocked('0'); return; }
if (var < 0)
putchar_unlocked('-'),
var = -var;
char stack[32]; int stack_p = 0;
while (var)
stack[stack_p++] = '0' + (var % 10),
var /= 10;
while (stack_p)
putchar_unlocked(stack[--stack_p]);
}
inline MaiPrinter& operator<<(char c) noexcept { putchar_unlocked(c); return *this; }
inline MaiPrinter& operator<<(int var) noexcept { output_integer<int>(var); return *this; }
inline MaiPrinter& operator<<(long long var) noexcept { output_integer<long long>(var); return *this; }
inline MaiPrinter& operator<<(char* str_p) noexcept { while (*str_p) putchar_unlocked(*(str_p++)); return *this; }
inline MaiPrinter& operator<<(const string& str) {
const char* p = str.c_str();
const char* l = p + str.size();
while (p < l) putchar_unlocked(*p++);
return *this;
}
template<typename IT> void join(IT begin, IT end, char sep = ' ') { for (bool b = 0; begin != end; ++begin, b = 1) b ? *this << sep << *begin : *this << *begin; }
};
}
MaiScanner scanner;
MaiPrinter printer;
template<typename T>
void output_float(T var, int d) noexcept {
if (var < 0)
putchar_unlocked('-'),
var = -var;
T i = floor(var);
printer << (long long)i;
var -= i;
putchar_unlocked('.');
while (d-- > 0 && var > 0) {
var *= 10.0;
int i = floor(var);
putchar_unlocked('0'+i);
var -= i;
}
}
const double answers[] = {0.0,6.0000000000000,6.0000000000000,6.0000000000000,6.0000000000000,6.0000000000000,6.0000000000000,9.9431493245813,10.3517072141596,10.8547142372268,11.4892025670690,12.3144747314929,13.4318070625894,15.0295693846048,15.7878045760563,16.6367584445299,17.5779328166767,18.6018762992286,19.6784204883806,20.7418920803449,21.6727532705183,22.6452492828499,23.6472607430786,24.6634729968039,25.6776441307129,26.6774687164191,27.6631486382800,28.6610317047456,29.6644774407028,30.6681988379491,31.6692102098178,32.6674219197726,33.6653088475290,34.6657600211366,35.6667407001552,36.6672069559259,37.6670039159395,38.6665549531407,39.6663795009348,40.6665950533338,41.6667623321706,42.6667666450969,43.6666792513314,44.6666150852285,45.6666269215973,46.6666754358131,47.6666911389834,48.6666772800717,49.6666599423689,50.6666562083220,51.6666641362904,52.6666712894863,53.6666704947738,54.6666665487965,55.6666645029945,56.6666653702276,57.6666671081772,58.6666676705989,59.6666669872858,60.6666663264548,61.6666662846528,62.6666666189358,63.6666668527626,64.6666668050261,65.6666666435509,66.6666665795408,67.6666666265889,68.6666666900472,69.6666667032230,70.6666666755595,71.6666666516459,72.6666666531390,73.6666666666933,74.6666666740687,75.6666666711342,76.6666666652487,77.6666666633599,78.6666666655030,79.6666666677623,80.6666666679573,81.6666666668434,82.6666666660620,83.6666666662100,84.6666666667277,85.6666666669500,86.6666666668027,87.6666666665937,88.6666666665483,89.6666666666363,90.6666666667133,91.6666666667107,92.6666666666676,93.6666666666433,94.6666666666523,95.6666666666709,96.6666666666772,97.6666666666706,98.6666666666635,99.6666666666626,100.6666666666661,101.6666666666685,102.6666666666682,103.6666666666666,104.6666666666657,105.6666666666663,106.6666666666669,107.6666666666671,108.6666666666667,109.6666666666667,110.6666666666666,111.6666666666667,112.6666666666667,113.6666666666667,114.6666666666667,115.6666666666667,116.6666666666668,117.6666666666666,118.6666666666666,119.6666666666667,120.6666666666668,121.6666666666666,122.6666666666666,123.6666666666667,124.6666666666666,125.6666666666666,126.6666666666668,127.6666666666667,128.6666666666667,129.6666666666666,130.6666666666669,131.6666666666667,132.6666666666668,133.6666666666668,134.6666666666667,135.6666666666668,136.6666666666668,137.6666666666668,138.6666666666666,139.6666666666666,140.6666666666666,141.6666666666669,142.6666666666667,143.6666666666666,144.6666666666669,145.6666666666668,146.6666666666667,147.6666666666667,148.6666666666667,149.6666666666668,150.6666666666667,151.6666666666669,152.6666666666668,153.6666666666666,154.6666666666668,155.6666666666667,156.6666666666665,157.6666666666668,158.6666666666667,159.6666666666666,160.6666666666665,161.6666666666665,162.6666666666664,163.6666666666667,164.6666666666665,165.6666666666664,166.6666666666663,167.6666666666662,168.6666666666664,169.6666666666662,170.6666666666660,171.6666666666662,172.6666666666660,173.6666666666664,174.6666666666661,175.6666666666663,176.6666666666661,177.6666666666659,178.6666666666663,179.6666666666661,180.6666666666662};
int main() {
int T;
scanner >> T;
map<ll, double> memo;
repeat(_, T) {
ll K;
scanner >> K;
if (K >= 180) output_float(5.0/3+K, 13);
else output_float(answers[K], 13);
printer << '\n';
}
return 0;
}