QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#437430 | #8785. Fake Coin and Lying Scales | ucup-team1004 | AC ✓ | 3842ms | 12124kb | C++14 | 1.8kb | 2024-06-09 10:32:44 | 2024-06-09 10:32:44 |
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=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<=3ll*k+1;j--){
tot+=ceil(exp(w+ln2*j+C(n,j))-1);
}
(tot>3ll*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';
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 12012kb
input:
2 100 0 100 1
output:
109.861228866 105.661523787
result:
ok q=0 (2 test cases)
Test #2:
score: 0
Accepted
time: 45ms
memory: 12120kb
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: 12116kb
input:
1 10000 0
output:
10986.122886681
result:
ok q=0 (1 test case)
Test #4:
score: 0
Accepted
time: 3ms
memory: 12032kb
input:
1 10000 10
output:
10905.241447591
result:
ok q=0 (1 test case)
Test #5:
score: 0
Accepted
time: 3ms
memory: 12036kb
input:
1 10000 100
output:
10365.308474316
result:
ok q=0 (1 test case)
Test #6:
score: 0
Accepted
time: 3ms
memory: 12108kb
input:
1 100000 0
output:
109861.228866810
result:
ok q=0 (1 test case)
Test #7:
score: 0
Accepted
time: 15ms
memory: 11984kb
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: 12036kb
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: 711ms
memory: 12108kb
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: 1205ms
memory: 11980kb
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: 52ms
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: 0
Accepted
time: 2215ms
memory: 12104kb
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 27.868579685 20.963615196 445375781.192487895 125531072.488063887 21.698875098 27488636.725950301 28988567.054943975 27.379698215 20.932756516 27.325295507 17333...
result:
ok q=0 (100000 test cases)
Test #13:
score: 0
Accepted
time: 3842ms
memory: 12124kb
input:
100000 998709247 6662353 938409567 5496364 470262254 388552 44631553 8053900 263812189 8140673 570847244 3686835 143527865 6364614 630983298 5151426 508843717 9845212 529080317 4866307 229185417 7424168 870671276 2477533 922155225 4868463 286532330 7131107 5469824 6272182 112064124 9288326 871839242...
output:
1052557875.925603628 993406422.696231842 513220014.367718697 22380606.137604725 247854665.960433811 602319074.126853347 127217813.945143580 659736907.199661016 503607563.088539183 550220072.768137574 213873957.170968741 937815585.804745436 979331031.693301201 276465511.113772392 16.750247200 8465373...
result:
ok q=0 (100000 test cases)
Test #14:
score: 0
Accepted
time: 64ms
memory: 12120kb
input:
100000 2388237 863104141 1949853 594471487 5788570 323905636 6626472 532884672 6478027 985480511 8713369 400770447 7877963 563355387 8572690 802705946 246447 691673591 1048191 39348128 9822372 87353076 4622806 985586908 3940664 689517333 7206000 907183324 7647553 126209541 9304319 816108273 3026286 ...
output:
21.674658204 21.301795601 20.694575074 21.192427873 21.807252198 20.907511659 21.248033514 21.602111300 21.453237002 18.586571256 19.384081101 21.807360156 21.450114683 21.724467398 19.752066399 21.618669881 21.236729894 20.856794884 21.460016464 21.223352925 20.953922450 21.317864909 21.105738117 2...
result:
ok q=0 (100000 test cases)
Test #15:
score: 0
Accepted
time: 50ms
memory: 12040kb
input:
100000 3230 990083111 447677 391972657 692146 408354973 191509 902573102 662501 450354073 721550 41375394 457751 109724688 636199 701346721 4329 135209393 7190 728002830 562092 480808431 608393 78791345 751611 613615532 576135 459945713 830181 180428675 549685 436319534 608642 828570290 40757 416064...
output:
21.811911737 20.885314932 20.926259675 21.719372533 21.024156950 18.636809211 19.612097242 21.467125221 19.820947485 21.504427783 21.089591766 19.280926007 21.333491410 21.045231315 20.109458396 20.992497698 21.633824520 20.944964242 20.832490550 20.884538945 21.525831124 18.952053982 21.270687700 2...
result:
ok q=0 (100000 test cases)
Test #16:
score: 0
Accepted
time: 52ms
memory: 12100kb
input:
100000 25834 61214455 26648 808954129 93315 645258548 40846 889138139 50931 688595112 83574 231579050 4476 298005500 10230 178645104 67274 582026639 45478 228216795 31799 640547396 76931 331956048 42831 764190687 32200 938076217 11303 774768820 48548 908303551 52646 376587760 30951 91507236 32097 76...
output:
19.028506207 21.609865062 21.383773933 21.704375457 21.448776300 20.359044132 20.611234790 20.099524027 21.280639065 20.344418881 21.376445964 20.719125422 21.552940195 21.757954047 21.566687535 21.725701477 20.845273962 19.430540901 21.547900800 21.498698437 20.822641628 20.181251128 21.638836155 1...
result:
ok q=0 (100000 test cases)
Test #17:
score: 0
Accepted
time: 3837ms
memory: 12112kb
input:
100000 274227737 68346059 218685007 54356465 989024364 38654736 621112634 30460344 744276614 23921662 244777456 92571767 802238000 396401 867445410 73326922 915786289 8870270 283682509 84172313 874633287 75201041 511367562 84949073 634359016 56041772 732833967 55417420 693037815 93779223 439536157 2...
output:
99920320.726547733 79945807.010364041 896551039.922604442 539707003.184136748 695323400.394103289 42420666.573627032 877659783.418978453 650860090.417866707 949986389.730130911 80819166.496555656 652369973.353182912 272959465.192391515 468593091.915300667 570331669.660359740 421678376.107176900 3810...
result:
ok q=0 (100000 test cases)
Test #18:
score: 0
Accepted
time: 3077ms
memory: 12120kb
input:
100000 145675394 9644 868401983 5079 81959359 7252 221259510 4525 210940342 503 709938567 8322 313226886 2026 284975389 1034 961263243 1271 708878403 8424 147154537 1117 597142707 9049 49009960 8469 632841549 912 998250617 5932 107131683 9999 243110679 3650 921083825 3103 645636937 7805 803218474 41...
output:
159931662.701527566 953967306.586982846 89961614.780732170 243021910.894523352 231734299.101391733 779838670.488812327 344087280.920843661 313062773.003580928 1056036267.239744186 778672745.709436417 161650735.723174185 655912590.976278424 53755250.919787280 695233703.715109229 1096608983.801394939 ...
result:
ok q=0 (100000 test cases)
Test #19:
score: 0
Accepted
time: 3113ms
memory: 12112kb
input:
100000 415903859 143863 726725861 220923 721402153 142794 636365369 56467 195687608 492519 244711303 612418 892437244 320712 965738323 66085 653139241 592706 2885567 920921 430945805 947767 493265196 74615 877041778 105313 477250612 324587 932782139 573227 651591411 492931 438774413 597150 816745072...
output:
455527059.176386476 796226817.096670985 791081849.815917492 698496398.185147643 211203946.282964468 264138078.744046867 977355968.031618953 1060226382.428062201 712391733.523754835 724792.936960509 466038730.965799689 541124547.893756270 962399890.122341633 521396652.602777660 1019556750.292551875 7...
result:
ok q=0 (100000 test cases)
Test #20:
score: 0
Accepted
time: 3081ms
memory: 12068kb
input:
100000 932735028 38475 303723723 37217 293643065 82693 53306635 90174 883367937 63149 414476477 62827 308746443 66010 319864936 52981 95584375 56035 201651629 95614 453621071 58910 638222297 35431 980668234 47930 725614760 41170 688105374 50896 958291243 76312 808245100 31656 617265859 68228 8643946...
output:
1024260599.724426270 333276402.725557148 321783884.453719437 57835244.235488139 969769150.543035150 454690073.658329308 338523081.547047794 350856629.298185706 104498327.318674952 220643283.143322378 497726775.631542861 700751703.573066711 1076817274.323369980 796697082.270736456 755390746.786230803...
result:
ok q=0 (100000 test cases)
Test #21:
score: 0
Accepted
time: 0ms
memory: 12004kb
input:
1 1000 1000000000
output:
21.821878126
result:
ok q=0 (1 test case)
Test #22:
score: 0
Accepted
time: 3ms
memory: 12040kb
input:
1 1 100000000
output:
19.519293036
result:
ok q=0 (1 test case)
Test #23:
score: 0
Accepted
time: 7ms
memory: 11984kb
input:
1 100 1000000000
output:
21.821878126
result:
ok q=0 (1 test case)
Test #24:
score: 0
Accepted
time: 7ms
memory: 12024kb
input:
1 1 1000000000
output:
21.821878126
result:
ok q=0 (1 test case)
Test #25:
score: 0
Accepted
time: 3ms
memory: 12004kb
input:
1 1000000000 1000000000
output:
21.821878126
result:
ok q=0 (1 test case)
Extra Test:
score: 0
Extra Test Passed