QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#437428#8785. Fake Coin and Lying Scalesucup-team1004WA 2038ms12152kbC++141.8kb2024-06-09 10:30:402024-06-09 10:30:40

Judging History

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

  • [2024-06-09 10:30:40]
  • 评测
  • 测评结果:WA
  • 用时:2038ms
  • 内存:12152kb
  • [2024-06-09 10:30:40]
  • 提交

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+20);
		for(int j=lim;j>=0&&j>=lim-40&&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';
}

详细

Test #1:

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

input:

2
100 0
100 1

output:

109.861228866
105.661523787

result:

ok q=0 (2 test cases)

Test #2:

score: 0
Accepted
time: 41ms
memory: 11880kb

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: 7ms
memory: 12128kb

input:

1
10000 0

output:

10986.122886681

result:

ok q=0 (1 test case)

Test #4:

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

input:

1
10000 10

output:

10905.241447591

result:

ok q=0 (1 test case)

Test #5:

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

input:

1
10000 100

output:

10365.308474316

result:

ok q=0 (1 test case)

Test #6:

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

input:

1
100000 0

output:

109861.228866810

result:

ok q=0 (1 test case)

Test #7:

score: 0
Accepted
time: 11ms
memory: 12152kb

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: 4ms
memory: 12080kb

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: 783ms
memory: 12120kb

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
17.606538590
14.277377423
14.888206227
14.108506238
14.526450013
353454.976782377
96659.062015152
14.720747218
7084.953281382
14.637038200
60919.695086387
188055.649039301
3072.784839559
555162.752722729
14.563150659
223400.816554918
20.255345618
165838.681052214
160145.721172709
14...

result:

ok q=0 (100000 test cases)

Test #10:

score: 0
Accepted
time: 1215ms
memory: 12020kb

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:

ok q=0 (100000 test cases)

Test #11:

score: 0
Accepted
time: 56ms
memory: 12120kb

input:

100000
3460 249080
4870 627106
7714 639325
6245 973410
5156 799724
2143 932101
3190 88015
5691 880401
4405 773261
157 516968
1022 535321
7679 193074
2293 754309
6302 607322
9422 65236
7327 352879
2188 417324
3181 532778
8804 165866
2433 321295
4829 557456
7228 613548
470 947610
2867 326654
1091 7711...

output:

13.524143036
14.447483685
14.466781021
14.887173281
14.690634653
14.843809103
12.483878609
14.786745432
14.656984636
14.254349189
14.289234757
13.269442829
14.632170108
14.415427245
12.184384141
13.872493734
14.040231265
14.284473020
13.117549811
13.778728309
14.329751742
14.425626612
14.860310945
1...

result:

ok q=0 (100000 test cases)

Test #12:

score: -100
Wrong Answer
time: 2038ms
memory: 12008kb

input:

100000
485911443 648621499
967545108 273118575
544774196 541753568
572826636 56596285
997351031 75012282
841305005 238445153
871651103 680174033
831928615 349267999
895576242 735170120
38669405 423897783
879163052 156607422
474161410 146955978
703868457 884260985
882781563 482183053
774752914 414027...

output:

21.388972187
297865547.107889295
27.314740358
405381381.782116115
777499095.337612867
257440440.292264640
27.777283609
105964409.664803684
0.000000000
20.963615196
445375781.192487895
125531072.488063887
21.698875098
27488636.725950301
28988567.054943975
27.379698215
20.932756516
27.325295507
173335...

result:

wrong answer WA (test case 9)