QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#278044 | #5557. Enjoyable Entree | jzh# | AC ✓ | 1ms | 3956kb | C++23 | 935b | 2023-12-07 11:06:26 | 2023-12-07 11:06:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using db = long double;
struct M{
array<array<db, 2>, 2> A;
M operator * (const M& t) const {
decltype(A) ans = {0,0,0,0};
for(int i = 0 ; i < 2 ; i ++) {
for(int j = 0 ; j < 2 ; j ++) {
for(int k = 0 ; k < 2 ; k ++) {
ans[i][j] += A[i][k] * t.A[k][j];
}
}
}
return M{ans};
}
};
M POW(M a, ll k) {
M ans = {1, 0, 0, 1};
for(; k; k/=2, a = a * a) {
if(k&1) ans = ans * a;
}
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(10);
int n; cin >> n;
if(n==1) {
cout << 100.0 << ' ' << 0.0 << endl;
return 0;
}
else if(n==2) {
cout << 0 << ' ' << 100 << endl;
return 0;
}
M a = {0.5, 0.5, 1, 0};
M trans = POW(a, n-2);
cout << 100 * trans.A[0][1] << ' ' << 100 * trans.A[0][0] << endl;;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3908kb
input:
1
output:
100.0000000000 0.0000000000
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
3
output:
50.0000000000 50.0000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
7
output:
34.3750000000 65.6250000000
result:
ok 2 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
2
output:
0 100
result:
ok 2 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
4
output:
25.0000000000 75.0000000000
result:
ok 2 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
5
output:
37.5000000000 62.5000000000
result:
ok 2 numbers
Test #7:
score: 0
Accepted
time: 1ms
memory: 3916kb
input:
6
output:
31.2500000000 68.7500000000
result:
ok 2 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
8
output:
32.8125000000 67.1875000000
result:
ok 2 numbers
Test #9:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
9
output:
33.5937500000 66.4062500000
result:
ok 2 numbers
Test #10:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
10
output:
33.2031250000 66.7968750000
result:
ok 2 numbers
Test #11:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
11
output:
33.3984375000 66.6015625000
result:
ok 2 numbers
Test #12:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
12
output:
33.3007812500 66.6992187500
result:
ok 2 numbers
Test #13:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
13
output:
33.3496093750 66.6503906250
result:
ok 2 numbers
Test #14:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
14
output:
33.3251953125 66.6748046875
result:
ok 2 numbers
Test #15:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
15
output:
33.3374023438 66.6625976562
result:
ok 2 numbers
Test #16:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
16
output:
33.3312988281 66.6687011719
result:
ok 2 numbers
Test #17:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
17
output:
33.3343505859 66.6656494141
result:
ok 2 numbers
Test #18:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
18
output:
33.3328247070 66.6671752930
result:
ok 2 numbers
Test #19:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
19
output:
33.3335876465 66.6664123535
result:
ok 2 numbers
Test #20:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
20
output:
33.3332061768 66.6667938232
result:
ok 2 numbers
Test #21:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
21
output:
33.3333969116 66.6666030884
result:
ok 2 numbers
Test #22:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
22
output:
33.3333015442 66.6666984558
result:
ok 2 numbers
Test #23:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
23
output:
33.3333492279 66.6666507721
result:
ok 2 numbers
Test #24:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
24
output:
33.3333253860 66.6666746140
result:
ok 2 numbers
Test #25:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
25
output:
33.3333373070 66.6666626930
result:
ok 2 numbers
Test #26:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
26
output:
33.3333313465 66.6666686535
result:
ok 2 numbers
Test #27:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
27
output:
33.3333343267 66.6666656733
result:
ok 2 numbers
Test #28:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
28
output:
33.3333328366 66.6666671634
result:
ok 2 numbers
Test #29:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
29
output:
33.3333335817 66.6666664183
result:
ok 2 numbers
Test #30:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
30
output:
33.3333332092 66.6666667908
result:
ok 2 numbers
Test #31:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
645
output:
33.3333333333 66.6666666667
result:
ok 2 numbers
Test #32:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
9664
output:
33.3333333333 66.6666666667
result:
ok 2 numbers
Test #33:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
92124
output:
33.3333333333 66.6666666667
result:
ok 2 numbers
Test #34:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
655217
output:
33.3333333333 66.6666666667
result:
ok 2 numbers
Test #35:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
1906604
output:
33.3333333333 66.6666666667
result:
ok 2 numbers
Test #36:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
14158782
output:
33.3333333333 66.6666666667
result:
ok 2 numbers
Test #37:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
118145010
output:
33.3333333333 66.6666666667
result:
ok 2 numbers
Test #38:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
2200494025
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #39:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
43605764225
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #40:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
804695488029
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #41:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
6627335577483
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #42:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
63784486977434
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #43:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
162874566997492
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #44:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
7889646630282564
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #45:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
93757501737327402
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #46:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
633156281075725080
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #47:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
999999999999999999
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #48:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
1000000000000000000
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #49:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
2147483646
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #50:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
2147483647
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #51:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
2147483648
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #52:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
2147483649
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #53:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
4294967294
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #54:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
4294967295
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #55:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
4294967296
output:
33.3333333333 66.6666666666
result:
ok 2 numbers
Test #56:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
4294967297
output:
33.3333333333 66.6666666666
result:
ok 2 numbers