QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#437427#8785. Fake Coin and Lying Scalesucup-team1004TL 2810ms12124kbC++141.8kb2024-06-09 10:29:312024-06-09 10:29:31

Judging History

你现在查看的是最新测评结果

  • [2024-06-09 10:29:31]
  • 评测
  • 测评结果:TL
  • 用时:2810ms
  • 内存:12124kb
  • [2024-06-09 10:29:31]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e6+5,M=5e4+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,k;
db sum[N];
void init(){
	const int n=1e6;
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+log(i);
}
const db pis=log(2*acos(-1))/2;
db calc(int n){
	if(n<=1000000) return sum[n];
	return pis+log(n)*(n+0.5)-n;
}
db C(int x,int y){return calc(x)-calc(y)-calc(x-y);}
const db ln2=log(2),ln3=log(3);
void Solve(){
	int i,j;scanf("%d%d",&n,&k);
	if(n<=k){printf("%.9lf\n",log(3ll*k+1));return;}
	db l=0,r=2e9,mid;
	for(int i=1;i<=60;i++){
		mid=(l+r)/2;
		db tot=k+1;
		db w=mid-ln3*n;
		db lim=min(k,n*2/3+100);
		for(int j=lim;j>=0&&j>=lim-200&&tot<=3*k+1;j--){
			tot+=ceil(exp(w+ln2*j+C(n,j))-1);
		}
		(tot>3*k+1?r:l)=mid;
	}
	printf("%.9lf\n",l);
}
int main(){
	init();
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 12016kb

input:

2
100 0
100 1

output:

109.861228866
105.661523787

result:

ok q=0 (2 test cases)

Test #2:

score: 0
Accepted
time: 46ms
memory: 12068kb

input:

10000
32 6
45 98
67 57
35 70
29 3
22 81
59 12
48 16
63 69
99 36
60 36
32 47
73 91
81 30
7 7
71 57
38 60
35 19
92 40
3 17
21 71
54 62
95 67
60 50
10 20
19 80
64 73
10 21
70 97
84 3
26 22
38 47
37 38
31 91
11 37
73 17
75 98
8 74
73 60
87 10
94 48
35 73
18 14
88 25
61 54
39 59
100 90
70 98
73 21
92 11
...

output:

19.764610320
5.686975356
4.826409907
5.351858133
23.522647241
5.497168225
31.891961351
16.457027418
5.337538080
25.380685175
6.129038417
4.955827058
5.613128106
21.001578332
3.091042453
4.856065654
5.198497031
6.152934636
16.812923562
3.951243719
5.365976015
5.231108617
5.160162233
4.718614674
4.110...

result:

ok q=0 (10000 test cases)

Test #3:

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

input:

1
10000 0

output:

10986.122886681

result:

ok q=0 (1 test case)

Test #4:

score: 0
Accepted
time: 7ms
memory: 12036kb

input:

1
10000 10

output:

10905.241447591

result:

ok q=0 (1 test case)

Test #5:

score: 0
Accepted
time: 7ms
memory: 12124kb

input:

1
10000 100

output:

10365.308474316

result:

ok q=0 (1 test case)

Test #6:

score: 0
Accepted
time: 7ms
memory: 12016kb

input:

1
100000 0

output:

109861.228866810

result:

ok q=0 (1 test case)

Test #7:

score: 0
Accepted
time: 14ms
memory: 12008kb

input:

1000
867 38
906 28
876 34
182 38
692 59
986 55
675 20
699 12
741 82
154 11
264 6
682 4
176 19
728 69
37 95
501 56
998 96
495 52
359 86
750 19
726 39
794 6
268 16
609 70
414 45
182 19
123 68
909 56
880 71
419 8
679 14
363 16
751 35
299 73
852 35
901 36
903 63
425 85
416 33
80 89
863 91
491 32
603 84
...

output:

777.207504101
857.635811395
801.903983116
87.202472221
525.323796801
840.501726331
643.739517811
704.317447725
507.557507133
127.158544524
261.620483954
725.764964666
125.905114992
531.641357521
5.655991811
343.678294427
722.237244422
348.875277414
145.138745782
728.241373097
625.660093862
837.23990...

result:

ok q=0 (1000 test cases)

Test #8:

score: 0
Accepted
time: 8ms
memory: 12112kb

input:

1000
71 766
31 464
8 194
12 296
69 506
55 518
31 237
73 576
50 685
1 137
29 661
58 508
46 870
33 172
66 94
41 634
38 725
94 163
94 45
34 685
71 486
95 511
37 108
54 643
64 94
1 624
48 283
1 64
23 122
3 866
52 798
68 669
43 460
68 187
50 403
31 877
100 191
44 512
33 50
91 732
37 584
22 501
46 93
81 7...

output:

7.740229525
7.239214974
6.368187186
6.790097236
7.325807503
7.349230825
6.568077911
7.455298486
7.628517627
6.021023349
7.592870288
7.329749689
7.867488569
6.248042875
5.645446898
7.551186867
7.685243608
6.194405391
13.476719529
7.628517627
7.285506549
7.335633982
5.783825182
7.565275282
5.645446898...

result:

ok q=0 (1000 test cases)

Test #9:

score: 0
Accepted
time: 2810ms
memory: 12112kb

input:

100000
448906 73251
858780 829062
380117 529011
219451 974416
390411 446812
457769 678634
440286 29979
663948 267273
623318 824172
557346 329036
2366 757990
279231 95725
394222 75586
671713 417299
997686 156089
462641 704003
267172 15563
115033 76151
271539 36507
909436 341831
97232 987703
780566 75...

output:

242699.764108293
16.025277241
14.277377423
14.888206227
14.108506238
14.526450013
353454.976782377
96659.062015152
14.720747218
7084.953281382
14.637038200
60919.695086387
188055.649039301
3072.784561846
555162.752722729
14.563150659
223400.816554918
19.775731191
165838.681052214
160145.721172709
14...

result:

ok q=0 (100000 test cases)

Test #10:

score: -100
Time Limit Exceeded

input:

100000
740599 913
947030 8115
575926 9039
721122 7094
794424 8453
157723 6263
973352 1890
462079 302
333631 3870
435636 4238
572643 7448
775859 6119
343386 2778
486927 1883
880553 7918
878758 5150
274829 778
759586 5734
461205 6806
744940 1346
378522 4830
214767 1511
367452 9987
288068 9685
761467 1...

output:

805982.007593423
988104.591719588
579949.691711927
747486.876554293
820109.302871195
142607.385849054
1054349.704166078
504930.029958354
342767.418780029
451820.868349483
584224.119687511
812415.041481987
359187.312161238
521311.822941848
916725.826533344
930255.685438924
296061.281279680
796799.901...

result: