QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#437392#8785. Fake Coin and Lying Scalesucup-team1004TL 193ms4308kbC++141.4kb2024-06-09 09:46:362024-06-09 09:46:37

Judging History

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

  • [2024-06-09 09:46:37]
  • 评测
  • 测评结果:TL
  • 用时:193ms
  • 内存:4308kb
  • [2024-06-09 09:46:36]
  • 提交

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=3e4+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;
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-log(3)*n;
		for(int j=0;j<=k;j++){
			tot+=ceil(exp(w)-1);
			w=w+log(n-j)-log(j+1)+log(2);
		}
		(tot>3*k+1?r:l)=mid;
	}
	printf("%.9lf\n",l);
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4264kb

input:

2
100 0
100 1

output:

109.861228866
105.661523787

result:

ok q=0 (2 test cases)

Test #2:

score: 0
Accepted
time: 193ms
memory: 4228kb

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.915417488
5.351858133
23.522647241
5.497168225
31.891961351
16.457027418
5.337538080
25.563006732
6.212715840
4.955827058
5.613128106
21.125261091
3.091042453
4.902726301
5.198497031
6.152934636
16.969766033
3.951243719
5.365976015
5.231108617
5.303874062
4.758680080
4.110...

result:

ok q=0 (10000 test cases)

Test #3:

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

input:

1
10000 0

output:

10986.122886681

result:

ok q=0 (1 test case)

Test #4:

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

input:

1
10000 10

output:

10905.455021692

result:

ok q=0 (1 test case)

Test #5:

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

input:

1
10000 100

output:

10365.686910751

result:

ok q=0 (1 test case)

Test #6:

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

input:

1
100000 0

output:

109861.228866810

result:

ok q=0 (1 test case)

Test #7:

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

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.511499749
857.910248241
802.206263988
87.437311811
525.650193386
840.836874941
643.977189463
704.499769282
507.901278672
127.201104138
261.620483954
725.764964666
126.078386713
531.976755067
5.655991811
343.989072215
722.590653169
349.182762113
145.461519174
728.489834456
625.970248790
837.23990...

result:

ok q=0 (1000 test cases)

Test #8:

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

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.638347186
7.628517627
7.285506549
7.335633982
5.783825182
7.565275282
5.645446898...

result:

ok q=0 (1000 test cases)

Test #9:

score: -100
Time Limit Exceeded

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:


result: