QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#442803 | #8785. Fake Coin and Lying Scales | zhangmj2008 | WA | 63ms | 4040kb | C++17 | 1.2kb | 2024-06-15 13:32:09 | 2024-06-15 13:32:09 |
Judging History
answer
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
using uint = unsigned int; using i64 = long long; using ui64 = unsigned long long; using i128 = __int128;
const int INF = 1e9; const i64 LLNF = 4e18;
template< class Tp > void chkmax( Tp &x, Tp y ) { x = max( x, y ); }
template< class Tp > void chkmin( Tp &x, Tp y ) { x = min( x, y ); }
using ld = double;
constexpr int B = 100; vector< ld > fact;
void prework( ) { fact = vector< ld >( B + 1 ); fact[1] = 0; for( int i = 2; i <= B; i ++ ) fact[i] = fact[i - 1] + log( i ); }
ld factorial( int n ) { if( n <= B ) return fact[n]; else return n * log( n ) - n; }
ld binom( int n, int m ) { if( m < 0 || m > n ) return -INFINITY; else return factorial( n ) - factorial( m ) - factorial( n - m ); }
// Phi( n, m ) = log( sum( binom( n, k ) * 2 ^ k: 0 <= k <= m ) )
ld Phi( int n, int m ) { int k = min( m, 2 * n / 3 ); return binom( n, k ) + log( 2 ) * k; }
void solve( ) {
int n, m; cin >> n >> m;
cout << fixed << setprecision( 10 ) << log( 3 * m + 1 ) + n * log( 3 ) - Phi( n, m ) << "\n";
}
int main( ) {
ios::sync_with_stdio( 0 ), cin.tie( 0 ), cout.tie( 0 );
prework( ); int T; cin >> T; while( T -- ) solve( ); return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
2 100 0 100 1
output:
109.8612288668 105.9492058614
result:
ok q=0 (2 test cases)
Test #2:
score: 0
Accepted
time: 5ms
memory: 3968kb
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:
20.2241426501 7.7636870232 7.4430544761 7.3186175437 23.8793221858 7.2872207818 32.3673850489 17.0907511792 7.5806345812 26.0954715321 7.5310372187 6.8798167915 7.9494403805 21.7042949648 4.4533916903 7.4567780786 7.2046549482 7.2176453729 17.6384221947 4.7621739348 7.0690171945 7.3979011918 7.76037...
result:
ok q=0 (10000 test cases)
Test #3:
score: 0
Accepted
time: 0ms
memory: 4016kb
input:
1 10000 0
output:
10986.1228866811
result:
ok q=0 (1 test case)
Test #4:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
1 10000 10
output:
10905.6314126008
result:
ok q=0 (1 test case)
Test #5:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
1 10000 100
output:
10365.7222922981
result:
ok q=0 (1 test case)
Test #6:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
1 100000 0
output:
109861.2288668110
result:
ok q=0 (1 test case)
Test #7:
score: 0
Accepted
time: 1ms
memory: 3968kb
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.6441078953 858.0511048080 802.3389935964 87.8448725102 525.8139284469 840.9602764395 644.1518545668 704.7181459559 508.0756640142 127.5864231947 262.0114609953 726.1356299116 126.4117018857 532.1383232451 7.6753949545 344.1946092859 722.7392958450 349.3818272685 145.8419934306 728.6510814475 626...
result:
ok q=0 (1000 test cases)
Test #8:
score: 0
Accepted
time: 1ms
memory: 4020kb
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:
10.0495131265 9.1789530646 7.6659979022 8.2237094925 9.6139873946 9.5517414821 8.5078160022 9.7916107598 9.7670486174 7.1196356380 9.4700880217 9.5571932282 9.9867598499 8.1720326084 7.9115930117 9.5938648559 9.6914015250 8.6517944810 14.4190825016 9.6096657743 9.5947901503 9.7877460147 7.8032283261...
result:
ok q=0 (1000 test cases)
Test #9:
score: 0
Accepted
time: 60ms
memory: 3972kb
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:
242693.8414425428 14.7266629100 14.2773780806 14.8882107837 14.1085062383 14.5264505592 353449.3816252095 96652.9688728172 14.7207476193 7079.8090649057 14.6371438565 60913.9590725856 188049.7517171232 3068.0010060286 555156.4425323715 14.5631511994 223395.5380747811 17.9804107752 165833.0679556715 ...
result:
ok q=0 (100000 test cases)
Test #10:
score: 0
Accepted
time: 63ms
memory: 3880kb
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:
805978.0866425572 988099.5860437318 579944.6394097178 747481.9394319318 820104.2789160373 142602.5421983445 1054345.4201599315 504926.6607712599 342762.7864009985 451816.1886300367 584219.1614086165 812410.1762793714 359182.8418828659 521307.5428221995 916720.8335910529 930250.9043964607 296057.4418...
result:
ok q=0 (100000 test cases)
Test #11:
score: 0
Accepted
time: 53ms
memory: 3888kb
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.5244320254 14.4476890093 14.4669106501 14.8872133117 14.6906831382 14.8442756662 12.4841920563 14.7867454318 14.6572116334 17.1663620198 14.2894793358 13.2694753848 14.6326061545 14.4154669136 12.1844106743 13.8726302095 14.0406882337 14.2847873540 13.1175782064 13.7787283093 14.3298035108 14.425...
result:
ok q=0 (100000 test cases)
Test #12:
score: -100
Wrong Answer
time: 49ms
memory: 4040kb
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.3889722824 297865537.2665129900 21.2089335918 405381372.4513075948 777499085.8381696939 257440430.5209509134 21.4364715815 105964400.0369997025 -nan 20.9636152536 445375771.4571757317 125531063.0115738511 -nan 27488627.5314886570 28988557.8559976816 21.1228002310 20.9327567220 21.2007993460 17333...
result:
wrong output format Expected double, but "-nan" found (test case 9)