QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#48580#4003. Rounding Master_Vans_#AC ✓4ms3880kbC++1.2kb2022-09-14 16:09:112022-09-14 16:09:13

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-14 16:09:13]
  • Judged
  • Verdict: AC
  • Time: 4ms
  • Memory: 3880kb
  • [2022-09-14 16:09:11]
  • Submitted

answer

/*
 * @Autor: Van
 * @Date: 2022-09-14 16:08:12
 * @FilePath: \vsCode\.vscode\codes\23training_2\J.cpp
 * @LastEditTime: 2022-09-14 16:08:25
 * @Description: 二分答案
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include<unordered_map>
#include<iomanip>

#define pii pair<int,int>
#define ll long long

using namespace std;

const int INF=0x7fffffff;
long double n,k,u;
const long long maxn = 1e18;

bool check(long double x)
{
	long double nowans=1;
	long long times=0;
	for(int i=1;i<=k;i++)
	{
		nowans*=x;
		nowans=round(nowans);
	}
	if(nowans>=n)
		return 1;
	else
		return 0;
}

int main()
{
	cin>>n>>k;
    if(n==1)
	{
        printf("0.5");
        return 0;
    }
    if(k>=110)
	{
        printf("1.5");
        return 0;
    }
    if(k==1)
	{
        printf("%.6Lf",n-0.5);
        return 0;
    }
	long double l=1.5,r=n;

	while(r-l>1e-7)
	{
		long double mid=l+(r-l)/2;
		if(check(mid))
			r=mid;
		else
			l=mid;
	}
	 
	printf("%.8Lf",r);

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3608kb

input:

18 4

output:

2.12500002

result:

ok found '2.1250000', expected '2.1250000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

1 1

output:

0.5

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

1000000000000000000 1000000000000000000

output:

1.5

result:

ok found '1.5000000', expected '1.5000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3720kb

input:

2 100000

output:

1.5

result:

ok found '1.5000000', expected '1.5000000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3876kb

input:

1 1000000000000000000

output:

0.5

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

1000000000000000000 1

output:

999999999999999999.500000

result:

ok found '1000000000000000000.0000000', expected '1000000000000000000.0000000', error '0.0000000'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

2 1000000000000000000

output:

1.5

result:

ok found '1.5000000', expected '1.5000000', error '0.0000000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

1000000000000000000 2

output:

1000000000.00000004

result:

ok found '1000000000.0000000', expected '1000000000.0000000', error '0.0000000'

Test #9:

score: 0
Accepted
time: 3ms
memory: 3632kb

input:

265714758284843011 6476356347841896

output:

1.5

result:

ok found '1.5000000', expected '1.5000000', error '0.0000000'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

266540997167959139 92

output:

1.54166667

result:

ok found '1.5416667', expected '1.5416667', error '0.0000000'

Test #11:

score: 0
Accepted
time: 3ms
memory: 3680kb

input:

998169857863230070 46

output:

2.47406673

result:

ok found '2.4740667', expected '2.4740667', error '0.0000000'

Test #12:

score: 0
Accepted
time: 3ms
memory: 3808kb

input:

762322967106512617 94

output:

1.54428846

result:

ok found '1.5442885', expected '1.5442884', error '0.0000000'

Test #13:

score: 0
Accepted
time: 3ms
memory: 3784kb

input:

494087735053841727 1

output:

494087735053841726.500000

result:

ok found '494087735053841728.0000000', expected '494087735053841728.0000000', error '0.0000000'

Test #14:

score: 0
Accepted
time: 3ms
memory: 3692kb

input:

58564077538358873 97

output:

1.50000010

result:

ok found '1.5000001', expected '1.5000000', error '0.0000001'

Test #15:

score: 0
Accepted
time: 3ms
memory: 3740kb

input:

518101003270379436 40

output:

2.76999475

result:

ok found '2.7699947', expected '2.7699947', error '0.0000000'

Test #16:

score: 0
Accepted
time: 4ms
memory: 3808kb

input:

278796295010358752 12

output:

28.46974492

result:

ok found '28.4697449', expected '28.4697449', error '0.0000000'

Test #17:

score: 0
Accepted
time: 3ms
memory: 3672kb

input:

679814304673935850 67

output:

1.84243684

result:

ok found '1.8424368', expected '1.8424368', error '0.0000000'

Test #18:

score: 0
Accepted
time: 3ms
memory: 3720kb

input:

963457718519969787 22

output:

6.54731541

result:

ok found '6.5473154', expected '6.5473154', error '0.0000000'

Test #19:

score: 0
Accepted
time: 2ms
memory: 3792kb

input:

267367244641009859 41

output:

2.65295067

result:

ok found '2.6529507', expected '2.6529507', error '0.0000000'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

740983904691688417 65

output:

1.87759683

result:

ok found '1.8775968', expected '1.8775968', error '0.0000000'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

941365965213552512 82

output:

1.65531691

result:

ok found '1.6553169', expected '1.6553168', error '0.0000000'

Test #22:

score: 0
Accepted
time: 3ms
memory: 3880kb

input:

284337374294498000 38

output:

2.87220170

result:

ok found '2.8722017', expected '2.8722016', error '0.0000000'

Test #23:

score: 0
Accepted
time: 2ms
memory: 3876kb

input:

812120465372795700 38

output:

2.95631556

result:

ok found '2.9563156', expected '2.9563155', error '0.0000000'

Test #24:

score: 0
Accepted
time: 3ms
memory: 3824kb

input:

564561304973603673 7

output:

343.50000004

result:

ok found '343.5000000', expected '343.5000000', error '0.0000000'

Test #25:

score: 0
Accepted
time: 2ms
memory: 3824kb

input:

333368798444245171 30

output:

3.83461285

result:

ok found '3.8346129', expected '3.8346128', error '0.0000000'

Test #26:

score: 0
Accepted
time: 4ms
memory: 3824kb

input:

959976653971901732 69

output:

1.81705085

result:

ok found '1.8170508', expected '1.8170508', error '0.0000000'

Test #27:

score: 0
Accepted
time: 3ms
memory: 3780kb

input:

268193483524125987 37

output:

2.95456828

result:

ok found '2.9545683', expected '2.9545683', error '0.0000000'

Test #28:

score: 0
Accepted
time: 3ms
memory: 3804kb

input:

260425914665370955 71

output:

1.75299200

result:

ok found '1.7529920', expected '1.7529920', error '0.0000000'

Test #29:

score: 0
Accepted
time: 3ms
memory: 3716kb

input:

897036930760783895 17

output:

11.40400001

result:

ok found '11.4040000', expected '11.4040000', error '0.0000000'

Test #30:

score: 0
Accepted
time: 3ms
memory: 3740kb

input:

74587017830121569 24

output:

5.05158734

result:

ok found '5.0515873', expected '5.0515873', error '0.0000000'

Test #31:

score: 0
Accepted
time: 3ms
memory: 3716kb

input:

565676857502199822 83

output:

1.63450799

result:

ok found '1.6345080', expected '1.6345080', error '0.0000000'

Test #32:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

834393643531603718 27

output:

4.59558822

result:

ok found '4.5955882', expected '4.5955882', error '0.0000000'

Test #33:

score: 0
Accepted
time: 3ms
memory: 3732kb

input:

611313338732907397 47

output:

2.39655177

result:

ok found '2.3965518', expected '2.3965517', error '0.0000000'

Test #34:

score: 0
Accepted
time: 3ms
memory: 3804kb

input:

269019726702209411 91

output:

1.54913516

result:

ok found '1.5491352', expected '1.5491351', error '0.0000000'

Test #35:

score: 0
Accepted
time: 3ms
memory: 3876kb

input:

779867924639053494 90

output:

1.57577416

result:

ok found '1.5757742', expected '1.5757741', error '0.0000000'

Test #36:

score: 0
Accepted
time: 3ms
memory: 3732kb

input:

76079933162791087 6

output:

650.93525927

result:

ok found '650.9352593', expected '650.9352593', error '0.0000000'

Test #37:

score: 0
Accepted
time: 3ms
memory: 3708kb

input:

864836661365745138 48

output:

2.37054889

result:

ok found '2.3705489', expected '2.3705488', error '0.0000000'

Test #38:

score: 0
Accepted
time: 3ms
memory: 3792kb

input:

319233245336636649 83

output:

1.62255764

result:

ok found '1.6225576', expected '1.6225576', error '0.0000000'

Test #39:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

880853945234827955 98

output:

1.51874817

result:

ok found '1.5187482', expected '1.5187481', error '0.0000000'

Test #40:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

269845965585325539 86

output:

1.59021399

result:

ok found '1.5902140', expected '1.5902140', error '0.0000000'

Test #41:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

299309934612736033 50

output:

2.24716144

result:

ok found '2.2471614', expected '2.2471614', error '0.0000000'

Test #42:

score: 0
Accepted
time: 3ms
memory: 3736kb

input:

31750903004989766 46

output:

2.28921746

result:

ok found '2.2892175', expected '2.2892174', error '0.0000000'

Test #43:

score: 0
Accepted
time: 1ms
memory: 3728kb

input:

878458341756144515 26

output:

4.89875033

result:

ok found '4.8987503', expected '4.8987503', error '0.0000000'

Test #44:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

72789637466040772 32

output:

3.37780333

result:

ok found '3.3778033', expected '3.3778033', error '0.0000000'

Test #45:

score: 0
Accepted
time: 3ms
memory: 3612kb

input:

270672213058376259 95

output:

1.52010654

result:

ok found '1.5201065', expected '1.5201065', error '0.0000000'

Test #46:

score: 0
Accepted
time: 3ms
memory: 3736kb

input:

42123981441194380 57

output:

1.95421951

result:

ok found '1.9542195', expected '1.9542195', error '0.0000000'

Test #47:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

423890230884993629 93

output:

1.54168571

result:

ok found '1.5416857', expected '1.5416857', error '0.0000000'

Test #48:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

668707985291768083 4

output:

28596.33702972

result:

ok found '28596.3370297', expected '28596.3370297', error '0.0000000'

Test #49:

score: 0
Accepted
time: 3ms
memory: 3708kb

input:

271498451941492387 52

output:

2.16864931

result:

ok found '2.1686493', expected '2.1686493', error '0.0000000'

Test #50:

score: 0
Accepted
time: 2ms
memory: 3876kb

input:

561565987119909623 68

output:

1.81875000

result:

ok found '1.8187500', expected '1.8187500', error '0.0000000'

Test #51:

score: 0
Accepted
time: 3ms
memory: 3780kb

input:

166464870954228340 74

output:

1.70810467

result:

ok found '1.7081047', expected '1.7081047', error '0.0000000'

Test #52:

score: 0
Accepted
time: 3ms
memory: 3740kb

input:

272324690824608515 48

output:

2.30842157

result:

ok found '2.3084216', expected '2.3084215', error '0.0000000'

Test #53:

score: 0
Accepted
time: 3ms
memory: 3608kb

input:

81007997093592161 28

output:

4.01887711

result:

ok found '4.0188771', expected '4.0188771', error '0.0000000'

Test #54:

score: 0
Accepted
time: 3ms
memory: 3824kb

input:

273150934002691939 102

output:

1.50000006

result:

ok found '1.5000001', expected '1.5000000', error '0.0000000'

Test #55:

score: 0
Accepted
time: 3ms
memory: 3788kb

input:

1000000000000000000 101

output:

1.50019511

result:

ok found '1.5001951', expected '1.5001951', error '0.0000000'