QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#373732 | #5557. Enjoyable Entree | kevinyang# | AC ✓ | 1ms | 4056kb | C++20 | 7.9kb | 2024-04-02 02:39:57 | 2024-04-02 02:39:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
/* Macros {{{ */
/* A lot of this is from some of Benq's submissions
[https://codeforces.com/profile/Benq]
Ugly af to the eyes, but with vim fold its barable
Hopefully c++20 concepts can make all this stuff must cleaner */
/* Basics {{{ */
using ll = long long;
using ld = long double;
using str = string;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
#define mp make_pair
#define fi first
#define se second
#define arr array
#define ve vector
using vi = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
using vpi = vector<pi>;
using vpll = vector<pll>;
using vpld = vector<pld>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvld = vector<vld>;
using vvpi = vector<vpi>;
using vvpll = vector<vpll>;
using vvpld = vector<vpld>;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz size()
#define rsz(a) resize(a)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define For(i, a, b) for (int i = a; i < b; ++i)
#define Rof(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define rep(a) For(_, 0, a)
#define each(a, x) for (auto &a : x)
#define reach(a, x) for (auto a = x.rbegin(); a != x.rend(); ++a)
template <typename T, typename U>
inline void cmin(T &x, U y) {
if (y < x) x = y;
}
template <typename T, typename U>
inline void cmax(T &x, U y) {
if (x < y) x = y;
}
/*}}}*/
/* IO {{{ */
/* Template Macros {{{ */
#define tcT template <class T
#define tcTU tcT, class U
#define tcTUU tcT, class... U
/*}}}*/
inline namespace Helpers { /*{{{*/
tcT, class = void > struct is_iterable : false_type {};
tcT > struct is_iterable<
T, void_t<decltype(begin(declval<T>())), decltype(end(declval<T>()))>>
: true_type {};
tcT > constexpr bool is_iterable_v = is_iterable<T>::value;
tcT, class = void > struct is_readable : false_type {};
tcT > struct is_readable<T, typename std::enable_if_t<is_same_v<
decltype(cin >> declval<T &>()), istream &>>>
: true_type {};
tcT > constexpr bool is_readable_v = is_readable<T>::value;
tcT, class = void > struct is_printable : false_type {};
tcT > struct is_printable<T, typename std::enable_if_t<is_same_v<
decltype(cout << declval<T>()), ostream &>>>
: true_type {};
tcT > constexpr bool is_printable_v = is_printable<T>::value;
} /* namespace Helpers */
/*}}}*/
inline namespace Input { /*{{{*/
tcT > constexpr bool needs_input_v = !is_readable_v<T> && is_iterable_v<T>;
tcTUU > void re(T &t, U &...u);
tcTU > void re(pair<T, U> &p); /* pairs */
/* re: read{{{ */
tcT > typename enable_if<is_readable_v<T>, void>::type re(T &x) {
cin >> x;
} /* default */
tcT > typename enable_if<needs_input_v<T>, void>::type re(
T &i); // vectors, arrays, etc...
tcTU > void re(pair<T, U> &p) { re(p.fi, p.se); } // pairs
tcT > typename enable_if<needs_input_v<T>, void>::type re(T &i) {
each(x, i) re(x);
}
tcTUU > void re(T &t, U &...u) {
re(t);
re(u...);
} /* read multiple}}} */
/* rv: resize and read vectors{{{ */
void rv(size_t) {}
tcTUU > void rv(size_t N, ve<T> &t, U &...u);
template <class... U>
void rv(size_t, size_t N2, U &...u);
tcTUU > void rv(size_t N, ve<T> &t, U &...u) {
t.rsz(N);
re(t);
rv(N, u...);
}
template <class... U>
void rv(size_t, size_t N2, U &...u) {
rv(N2, u...);
} /*}}}*/
/* dumb shortcuts to read in ints{{{ */
void decrement() {} /* subtract one from each */
tcTUU > void decrement(T &t, U &...u) {
--t;
decrement(u...);
}
#define ints(...) \
int __VA_ARGS__; \
re(__VA_ARGS__);
#define int1(...) \
ints(__VA_ARGS__); \
decrement(__VA_ARGS__); /*}}}*/
} /* namespace Input */
/*}}}*/
inline namespace ToString { /*{{{*/
tcT > constexpr bool needs_output_v = !is_printable_v<T> && is_iterable_v<T>;
/* ts: string representation to print */
tcT > typename enable_if<is_printable_v<T>, str>::type ts(T v) {
stringstream ss;
ss << fixed << setprecision(15) << v;
return ss.str();
} /* default */
tcT > str bit_vec(T t) { /* bit vector to string */
str res = "{";
For(i, 0, t.sz) res += ts(t[i]);
res += "}";
return res;
}
str ts(ve<bool> v) { return bit_vec(v); }
template <size_t SZ>
str ts(bitset<SZ> b) {
return bit_vec(b);
} /* bit vector */
tcTU > str ts(pair<T, U> p); /* pairs */
tcT > typename enable_if<needs_output_v<T>, str>::type ts(
T v); /* vectors, arrays */
tcTU > str ts(pair<T, U> p) { return "(" + ts(p.fi) + ", " + ts(p.se) + ")"; }
tcT > typename enable_if<is_iterable_v<T>, str>::type ts_sep(T v, str sep) {
/* convert container to string w/ separator sep */
bool fst = 1;
str res = "";
for (const auto &x : v) {
if (!fst) res += sep;
fst = 0;
res += ts(x);
}
return res;
}
tcT > typename enable_if<needs_output_v<T>, str>::type ts(T v) {
return "{" + ts_sep(v, ", ") + "}";
}
/* for nested DS */
template <int, class T>
typename enable_if<!needs_output_v<T>, ve<str>>::type ts_lev(const T &v) {
return {ts(v)};
}
template <int lev, class T>
typename enable_if<needs_output_v<T>, ve<str>>::type ts_lev(const T &v) {
if (lev == 0 || !v.sz) return {ts(v)};
ve<str> res;
for (const auto &t : v) {
if (res.sz) res.back() += ",";
ve<str> tmp = ts_lev<lev - 1>(t);
res.insert(end(res), all(tmp));
}
For(i, 0, res.sz) {
str bef = " ";
if (i == 0) bef = "{";
res[i] = bef + res[i];
}
res.back() += "}";
return res;
}
} /* namespace ToString */
/*}}}*/
inline namespace Output { /*{{{*/
template <class T>
void pr_sep(ostream &os, str, const T &t) {
os << ts(t);
}
template <class T, class... U>
void pr_sep(ostream &os, str sep, const T &t, const U &...u) {
pr_sep(os, sep, t);
os << sep;
pr_sep(os, sep, u...);
}
/* print w/ no spaces */
template <class... T>
void pr(const T &...t) {
pr_sep(cout, "", t...);
}
/* print w/ spaces, end with newline */
void ps() { cout << "\n"; }
template <class... T>
void ps(const T &...t) {
pr_sep(cout, " ", t...);
ps();
}
/* debug to cerr */
template <class... T>
void dbg_out(const T &...t) {
pr_sep(cerr, " | ", t...);
cerr << endl;
}
void loc_info(int line, str names) {
cerr << "Line(" << line << ") -> [" << names << "]: ";
}
template <int lev, class T>
void dbgl_out(const T &t) {
cerr << "\n\n" << ts_sep(ts_lev<lev>(t), "\n") << "\n" << endl;
}
} /* namespace Output */
/*}}}}}}}}}*/
vvld mult_matrix(vvld &m1, vvld &m2) {
vvld res(2, vld(2, 0));
for(int r=0; r<2; ++r) for(int c=0; c<2; ++c)
for(int k=0; k<2; ++k) res[r][c] += m1[r][k] * m2[k][c];
return res;
}
vvld mtx_pow(vvld mtx, ll b) {
vvld res = { { 1, 0 }, { 0, 1 } };
ll e = 1;
vvld p = mtx;
for(; e <= b; e <<= 1, p = mult_matrix(p, p))
if(e&b) res = mult_matrix(res, p);
return res;
}
vvld my_mtx = {
{ 0, 1 },
{ 0.5, 0.5 }
};
ll n;
void solve() {
re(n);
vvld mtx = mtx_pow(my_mtx, n-1);
if(n > 1e6) {
ps(33.33333333333, 66.66666666666);
return;
}
ld r1 = mtx[0][0] * 100, r2 = mtx[0][1] * 100;
ps(r1, r2);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
/* cout << fixed << setprecision(6); */
int t = 1;
// cin >> t;
for (int i = 0; i < t; i++) solve();
return 0;
// you should actually read the stuff at the bottom
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3800kb
input:
1
output:
100.000000000000000 0.000000000000000
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 1ms
memory: 3844kb
input:
3
output:
50.000000000000000 50.000000000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
7
output:
34.375000000000000 65.625000000000000
result:
ok 2 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
2
output:
0.000000000000000 100.000000000000000
result:
ok 2 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 4040kb
input:
4
output:
25.000000000000000 75.000000000000000
result:
ok 2 numbers
Test #6:
score: 0
Accepted
time: 1ms
memory: 4040kb
input:
5
output:
37.500000000000000 62.500000000000000
result:
ok 2 numbers
Test #7:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
6
output:
31.250000000000000 68.750000000000000
result:
ok 2 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 4044kb
input:
8
output:
32.812500000000000 67.187500000000000
result:
ok 2 numbers
Test #9:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
9
output:
33.593750000000000 66.406250000000000
result:
ok 2 numbers
Test #10:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
10
output:
33.203125000000000 66.796875000000000
result:
ok 2 numbers
Test #11:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
11
output:
33.398437500000000 66.601562500000000
result:
ok 2 numbers
Test #12:
score: 0
Accepted
time: 1ms
memory: 3904kb
input:
12
output:
33.300781250000000 66.699218750000000
result:
ok 2 numbers
Test #13:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
13
output:
33.349609375000000 66.650390625000000
result:
ok 2 numbers
Test #14:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
14
output:
33.325195312500000 66.674804687500000
result:
ok 2 numbers
Test #15:
score: 0
Accepted
time: 1ms
memory: 3904kb
input:
15
output:
33.337402343750000 66.662597656250000
result:
ok 2 numbers
Test #16:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
16
output:
33.331298828125000 66.668701171875000
result:
ok 2 numbers
Test #17:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
17
output:
33.334350585937500 66.665649414062500
result:
ok 2 numbers
Test #18:
score: 0
Accepted
time: 0ms
memory: 4056kb
input:
18
output:
33.332824707031250 66.667175292968750
result:
ok 2 numbers
Test #19:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
19
output:
33.333587646484375 66.666412353515625
result:
ok 2 numbers
Test #20:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
20
output:
33.333206176757812 66.666793823242188
result:
ok 2 numbers
Test #21:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
21
output:
33.333396911621094 66.666603088378906
result:
ok 2 numbers
Test #22:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
22
output:
33.333301544189453 66.666698455810547
result:
ok 2 numbers
Test #23:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
23
output:
33.333349227905273 66.666650772094727
result:
ok 2 numbers
Test #24:
score: 0
Accepted
time: 0ms
memory: 4036kb
input:
24
output:
33.333325386047363 66.666674613952637
result:
ok 2 numbers
Test #25:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
25
output:
33.333337306976318 66.666662693023682
result:
ok 2 numbers
Test #26:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
26
output:
33.333331346511841 66.666668653488159
result:
ok 2 numbers
Test #27:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
27
output:
33.333334326744080 66.666665673255920
result:
ok 2 numbers
Test #28:
score: 0
Accepted
time: 1ms
memory: 3864kb
input:
28
output:
33.333332836627960 66.666667163372040
result:
ok 2 numbers
Test #29:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
29
output:
33.333333581686020 66.666666418313980
result:
ok 2 numbers
Test #30:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
30
output:
33.333333209156990 66.666666790843010
result:
ok 2 numbers
Test #31:
score: 0
Accepted
time: 0ms
memory: 4040kb
input:
645
output:
33.333333333333333 66.666666666666667
result:
ok 2 numbers
Test #32:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
9664
output:
33.333333333333333 66.666666666666667
result:
ok 2 numbers
Test #33:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
92124
output:
33.333333333333333 66.666666666666665
result:
ok 2 numbers
Test #34:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
655217
output:
33.333333333333328 66.666666666666656
result:
ok 2 numbers
Test #35:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
1906604
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #36:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
14158782
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #37:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
118145010
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #38:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
2200494025
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #39:
score: 0
Accepted
time: 0ms
memory: 4044kb
input:
43605764225
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #40:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
804695488029
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #41:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
6627335577483
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #42:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
63784486977434
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #43:
score: 0
Accepted
time: 0ms
memory: 4032kb
input:
162874566997492
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #44:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
7889646630282564
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #45:
score: 0
Accepted
time: 1ms
memory: 3868kb
input:
93757501737327402
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #46:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
633156281075725080
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #47:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
999999999999999999
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #48:
score: 0
Accepted
time: 1ms
memory: 3816kb
input:
1000000000000000000
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #49:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
2147483646
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #50:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
2147483647
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #51:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
2147483648
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #52:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
2147483649
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #53:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
4294967294
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #54:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
4294967295
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #55:
score: 0
Accepted
time: 0ms
memory: 4036kb
input:
4294967296
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers
Test #56:
score: 0
Accepted
time: 1ms
memory: 3860kb
input:
4294967297
output:
33.333333333330003 66.666666666660007
result:
ok 2 numbers