QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#437424 | #8785. Fake Coin and Lying Scales | ucup-team1004 | TL | 1070ms | 4352kb | C++14 | 1.7kb | 2024-06-09 10:23:05 | 2024-06-09 10:23:05 |
Judging History
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;
db calc(int n){
if(n<=30){
db tot=0;
for(int i=1;i<=n;i++) tot+=log(i);
return tot;
}
return log(2*acos(-1)*n)/2+(log(n)-1)*n;
}
db C(int x,int y){return calc(x)-calc(y)-calc(x-y);}
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;
gdb(exp(calc(1)));
for(int i=1;i<=60;i++){
mid=(l+r)/2;
db tot=k+1;
db w=mid-log(3)*n;
db lim=min(k,n*2/3+100);
for(int j=lim;j>=0&&j>=lim-200;j--){
tot+=ceil(exp(w+log(2)*j+C(n,j))-1);
}
(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';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4260kb
input:
2 100 0 100 1
output:
109.861228866 105.661515371
result:
ok q=0 (2 test cases)
Test #2:
score: 0
Accepted
time: 1070ms
memory: 4352kb
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.767214402 5.686975356 4.914888236 5.351858133 23.522647241 5.497168225 31.891600744 16.456159423 5.337538080 25.560210984 6.211723828 4.955827058 5.613128106 21.124655926 3.091042453 4.902297459 5.198497031 6.155315523 16.966985993 3.951243719 5.365976015 5.231108617 5.303507480 4.758295933 4.110...
result:
ok q=0 (10000 test cases)
Test #3:
score: 0
Accepted
time: 0ms
memory: 4264kb
input:
1 10000 0
output:
10986.122886681
result:
ok q=0 (1 test case)
Test #4:
score: 0
Accepted
time: 0ms
memory: 4236kb
input:
1 10000 10
output:
10905.455021684
result:
ok q=0 (1 test case)
Test #5:
score: 0
Accepted
time: 0ms
memory: 4324kb
input:
1 10000 100
output:
10365.686077336
result:
ok q=0 (1 test case)
Test #6:
score: 0
Accepted
time: 0ms
memory: 4268kb
input:
1 100000 0
output:
109861.228866810
result:
ok q=0 (1 test case)
Test #7:
score: 0
Accepted
time: 223ms
memory: 4332kb
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.509302411 857.910245308 802.203809236 87.434998051 525.648769746 840.835354813 643.977185693 704.499767199 507.900248423 127.201062513 261.620476614 725.764963946 126.078329414 531.975535361 5.655991811 343.987563203 722.589776229 349.181139808 145.460477063 728.489831568 625.968105569 837.23990...
result:
ok q=0 (1000 test cases)
Test #8:
score: 0
Accepted
time: 12ms
memory: 4248kb
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.635647073 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:
242699.765323991 16.025276666 14.277377423 14.888206227 14.108506238 14.526450013 353454.979873291 96659.062305493 14.720747218 7084.953351772 14.637038200 60919.695933904 188055.650208277 3072.784561551 555162.753293965 14.563150659 223400.822498585 19.775728687 165838.683541347 160145.721404078 14...