QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#142624 | #4003. Rounding Master | chenxinyang2006 | AC ✓ | 1ms | 3884kb | C++14 | 1.3kb | 2023-08-19 14:21:23 | 2023-08-19 14:21:26 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;
template <class T>
void chkmax(T &x,T y){
if(x < y) x = y;
}
template <class T>
void chkmin(T &x,T y){
if(x > y) x = y;
}
inline int popcnt(int x){
return __builtin_popcount(x);
}
inline int ctz(int x){
return __builtin_ctz(x);
}
/*ll power(ll p,int k = mod - 2){
ll ans = 1;
while(k){
if(k % 2 == 1) ans = ans * p % mod;
p = p * p % mod;
k /= 2;
}
return ans;
}*/
ll n,k;
#define eps 1e-7
int check(ldb V){
ldb cur = 1;
rep(i,1,k){
cur = cur * V + 0.5;
if(cur > 2e18) return 1;
cur = (ll)cur;
if(cur - n > -eps) return 1;
}
return 0;
}
int main(){
scanf("%lld%lld",&n,&k);
if(n == 1){
printf("0.50000000\n");
return 0;
}
ldb l = 1.5,r = n,mid;
while(r > l * (1 + eps)){
mid = (l + r) / 2;
if(check(mid)) r = mid;
else l = mid;
}
printf("%.10f\n",(db)l);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3768kb
input:
18 4
output:
2.1249998957
result:
ok found '2.1249999', expected '2.1250000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
1 1
output:
0.50000000
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
1000000000000000000 1000000000000000000
output:
1.5000000000
result:
ok found '1.5000000', expected '1.5000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
2 100000
output:
1.5000000000
result:
ok found '1.5000000', expected '1.5000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
1 1000000000000000000
output:
0.50000000
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
1000000000000000000 1
output:
999999940395355264.0000000000
result:
ok found '999999940395355264.0000000', expected '1000000000000000000.0000000', error '0.0000001'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
2 1000000000000000000
output:
1.5000000000
result:
ok found '1.5000000', expected '1.5000000', error '0.0000000'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
1000000000000000000 2
output:
999999973.2180684805
result:
ok found '999999973.2180685', expected '1000000000.0000000', error '0.0000000'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3832kb
input:
265714758284843011 6476356347841896
output:
1.5000000000
result:
ok found '1.5000000', expected '1.5000000', error '0.0000000'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
266540997167959139 92
output:
1.5416666182
result:
ok found '1.5416666', expected '1.5416667', error '0.0000000'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
998169857863230070 46
output:
2.4740665237
result:
ok found '2.4740665', expected '2.4740667', error '0.0000001'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
762322967106512617 94
output:
1.5442883852
result:
ok found '1.5442884', expected '1.5442884', error '0.0000000'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
494087735053841727 1
output:
494087705603917760.0000000000
result:
ok found '494087705603917760.0000000', expected '494087735053841728.0000000', error '0.0000001'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
58564077538358873 97
output:
1.5000000000
result:
ok found '1.5000000', expected '1.5000000', error '0.0000000'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
518101003270379436 40
output:
2.7699946920
result:
ok found '2.7699947', expected '2.7699947', error '0.0000000'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
278796295010358752 12
output:
28.4697435346
result:
ok found '28.4697435', expected '28.4697449', error '0.0000000'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
679814304673935850 67
output:
1.8424367004
result:
ok found '1.8424367', expected '1.8424368', error '0.0000001'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
963457718519969787 22
output:
6.5473152087
result:
ok found '6.5473152', expected '6.5473154', error '0.0000000'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
267367244641009859 41
output:
2.6529505601
result:
ok found '2.6529506', expected '2.6529507', error '0.0000000'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
740983904691688417 65
output:
1.8775967570
result:
ok found '1.8775968', expected '1.8775968', error '0.0000000'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
941365965213552512 82
output:
1.6553168108
result:
ok found '1.6553168', expected '1.6553168', error '0.0000000'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
284337374294498000 38
output:
2.8722015831
result:
ok found '2.8722016', expected '2.8722016', error '0.0000000'
Test #23:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
812120465372795700 38
output:
2.9563153914
result:
ok found '2.9563154', expected '2.9563155', error '0.0000000'
Test #24:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
564561304973603673 7
output:
343.4999870185
result:
ok found '343.4999870', expected '343.5000000', error '0.0000000'
Test #25:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
333368798444245171 30
output:
3.8346127140
result:
ok found '3.8346127', expected '3.8346128', error '0.0000000'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
959976653971901732 69
output:
1.8170507507
result:
ok found '1.8170508', expected '1.8170508', error '0.0000000'
Test #27:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
268193483524125987 37
output:
2.9545681707
result:
ok found '2.9545682', expected '2.9545683', error '0.0000000'
Test #28:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
260425914665370955 71
output:
1.7529919423
result:
ok found '1.7529919', expected '1.7529920', error '0.0000000'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
897036930760783895 17
output:
11.4039992687
result:
ok found '11.4039993', expected '11.4040000', error '0.0000001'
Test #30:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
74587017830121569 24
output:
5.0515870303
result:
ok found '5.0515870', expected '5.0515873', error '0.0000001'
Test #31:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
565676857502199822 83
output:
1.6345078685
result:
ok found '1.6345079', expected '1.6345080', error '0.0000001'
Test #32:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
834393643531603718 27
output:
4.5955881384
result:
ok found '4.5955881', expected '4.5955882', error '0.0000000'
Test #33:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
611313338732907397 47
output:
2.3965517092
result:
ok found '2.3965517', expected '2.3965517', error '0.0000000'
Test #34:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
269019726702209411 91
output:
1.5491350509
result:
ok found '1.5491351', expected '1.5491351', error '0.0000000'
Test #35:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
779867924639053494 90
output:
1.5757740753
result:
ok found '1.5757741', expected '1.5757741', error '0.0000000'
Test #36:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
76079933162791087 6
output:
650.9352529815
result:
ok found '650.9352530', expected '650.9352593', error '0.0000000'
Test #37:
score: 0
Accepted
time: 1ms
memory: 3832kb
input:
864836661365745138 48
output:
2.3705487110
result:
ok found '2.3705487', expected '2.3705488', error '0.0000000'
Test #38:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
319233245336636649 83
output:
1.6225575716
result:
ok found '1.6225576', expected '1.6225576', error '0.0000000'
Test #39:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
880853945234827955 98
output:
1.5187480756
result:
ok found '1.5187481', expected '1.5187481', error '0.0000000'
Test #40:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
269845965585325539 86
output:
1.5902138809
result:
ok found '1.5902139', expected '1.5902140', error '0.0000001'
Test #41:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
299309934612736033 50
output:
2.2471613182
result:
ok found '2.2471613', expected '2.2471614', error '0.0000000'
Test #42:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
31750903004989766 46
output:
2.2892173544
result:
ok found '2.2892174', expected '2.2892174', error '0.0000000'
Test #43:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
878458341756144515 26
output:
4.8987502406
result:
ok found '4.8987502', expected '4.8987503', error '0.0000000'
Test #44:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
72789637466040772 32
output:
3.3778032064
result:
ok found '3.3778032', expected '3.3778033', error '0.0000000'
Test #45:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
270672213058376259 95
output:
1.5201064254
result:
ok found '1.5201064', expected '1.5201065', error '0.0000001'
Test #46:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
42123981441194380 57
output:
1.9542194384
result:
ok found '1.9542194', expected '1.9542195', error '0.0000000'
Test #47:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
423890230884993629 93
output:
1.5416856230
result:
ok found '1.5416856', expected '1.5416857', error '0.0000000'
Test #48:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
668707985291768083 4
output:
28596.3360987082
result:
ok found '28596.3360987', expected '28596.3370297', error '0.0000000'
Test #49:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
271498451941492387 52
output:
2.1686491928
result:
ok found '2.1686492', expected '2.1686493', error '0.0000000'
Test #50:
score: 0
Accepted
time: 1ms
memory: 3884kb
input:
561565987119909623 68
output:
1.8187499430
result:
ok found '1.8187499', expected '1.8187500', error '0.0000000'
Test #51:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
166464870954228340 74
output:
1.7081045970
result:
ok found '1.7081046', expected '1.7081047', error '0.0000000'
Test #52:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
272324690824608515 48
output:
2.3084214580
result:
ok found '2.3084215', expected '2.3084215', error '0.0000000'
Test #53:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
81007997093592161 28
output:
4.0188769052
result:
ok found '4.0188769', expected '4.0188771', error '0.0000000'
Test #54:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
273150934002691939 102
output:
1.5000000000
result:
ok found '1.5000000', expected '1.5000000', error '0.0000000'
Test #55:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
1000000000000000000 101
output:
1.5001950078
result:
ok found '1.5001950', expected '1.5001951', error '0.0000000'