結果
問題 | No.1688 Veterinarian |
ユーザー | LayCurse |
提出日時 | 2021-09-04 07:53:12 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 68 ms / 3,000 ms |
コード長 | 4,944 bytes |
コンパイル時間 | 2,667 ms |
コンパイル使用メモリ | 226,808 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 09:52:13 |
合計ジャッジ時間 | 3,455 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 5 ms
5,376 KB |
testcase_08 | AC | 68 ms
5,376 KB |
testcase_09 | AC | 62 ms
5,376 KB |
testcase_10 | AC | 7 ms
5,376 KB |
testcase_11 | AC | 8 ms
5,376 KB |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 3 ms
5,376 KB |
testcase_15 | AC | 5 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("inline") #include<bits/stdc++.h> using namespace std; inline int my_getchar_unlocked(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread_unlocked(buf, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } return buf[s++]; } struct MY_WRITER{ char buf[1048576]; int s; int e; MY_WRITER(){ s = 0; e = 1048576; } ~MY_WRITER(){ if(s){ fwrite_unlocked(buf, 1, s, stdout); } } } ; MY_WRITER MY_WRITER_VAR; void my_putchar_unlocked(int a){ if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){ fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout); MY_WRITER_VAR.s = 0; } MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a; } inline void wt_L(char a){ my_putchar_unlocked(a); } int WRITER_DOUBLE_DIGIT = 15; inline int writerDigit_double(){ return WRITER_DOUBLE_DIGIT; } inline void writerDigit_double(int d){ WRITER_DOUBLE_DIGIT = d; } inline void wt_L(double x){ const int d = WRITER_DOUBLE_DIGIT; int k; int r; double v; if(x!=x || (x==x+1 && x==2*x)){ my_putchar_unlocked('E'); my_putchar_unlocked('r'); my_putchar_unlocked('r'); return; } if(x < 0){ my_putchar_unlocked('-'); x = -x; } x += 0.5 * pow(0.1, d); r = 0; v = 1; while(x >= 10*v){ v *= 10; r++; } while(r >= 0){ r--; k = floor(x / v); if(k >= 10){ k = 9; } if(k <= -1){ k = 0; } x -= k * v; v *= 0.1; my_putchar_unlocked(k + '0'); } if(d > 0){ my_putchar_unlocked('.'); v = 1; for(r=(0);r<(d);r++){ v *= 0.1; k = floor(x / v); if(k >= 10){ k = 9; } if(k <= -1){ k = 0; } x -= k * v; my_putchar_unlocked(k + '0'); } } } long long cReader_ll(long long mn, long long mx, char nx){ int i; int fg = 0; int m = 1; int f = -1; long long res = 0; double tmp = 0; for(;;){ i = my_getchar_unlocked(); if(fg==0 && i=='-'){ fg++; m = -1; } else if('0' <= i && i <= '9'){ fg++; if(f == -1){ f = i - '0'; } res = 10 * res + i - '0'; tmp = 10 * tmp + i - '0'; assert(tmp < 1e20); } else{ break; } } assert(tmp / 2 <= res); assert((m==1 && fg >= 1) || (m==-1 && fg >= 2)); assert(mn <= m * res && m * res <= mx); assert(!(res == 0 && m == -1)); assert(!(res != 0 && f == 0)); assert(!(res == 0 && fg >= 2)); assert(i == nx); return m * res; } void cReader_eof(){ int i; i = my_getchar_unlocked(); assert(i == EOF); } int A; int B; int C; int N; double dp[51][51][51]; double p[51][151]; double tmp; double res[3]; int main(){ int cTE1_r3A, i; A = cReader_ll(1, 50, ' '); B = cReader_ll(1, 50, ' '); C = cReader_ll(1, 50, ' '); N = cReader_ll(1, 50, '\n'); cReader_eof(); for(i=(1);i<(51);i++){ int j; for(j=(3);j<(151);j++){ p[i][j] = ((double) i * (i-1)) / ((double) j * (j-1)); } } dp[A][B][C] = 1; for(cTE1_r3A=(0);cTE1_r3A<(N);cTE1_r3A++){ for(i=(1);i<(A+1);i++){ int j; for(j=(1);j<(B+1);j++){ int k; for(k=(1);k<(C+1);k++){ tmp = dp[i][j][k]; dp[i-1][j][k] += tmp * p[i][i+j+k]; dp[i][j-1][k] += tmp * p[j][i+j+k]; dp[i][j][k-1] += tmp * p[k][i+j+k]; dp[i][j][k] -= tmp * (p[i][i+j+k] + p[j][i+j+k] + p[k][i+j+k]); } } } } for(i=(1);i<(A+1);i++){ int j; for(j=(1);j<(B+1);j++){ int k; for(k=(1);k<(C+1);k++){ res[0] += (A-i) * dp[i][j][k]; res[1] += (B-j) * dp[i][j][k]; res[2] += (C-k) * dp[i][j][k]; } } } { int jbtyPBGc; if(3==0){ wt_L('\n'); } else{ for(jbtyPBGc=(0);jbtyPBGc<(3-1);jbtyPBGc++){ wt_L(res[jbtyPBGc]); wt_L(' '); } wt_L(res[jbtyPBGc]); wt_L('\n'); } } return 0; } // cLay version 20210819-1 [beta] // --- original code --- // int A, B, C, N; // double dp[51][51][51], p[51][151], tmp, res[3]; // { // A = cReader_ll(1, 50, ' '); // B = cReader_ll(1, 50, ' '); // C = cReader_ll(1, 50, ' '); // N = cReader_ll(1, 50, '\n'); // cReader_eof(); // rep(i,1,51) rep(j,3,151) p[i][j] = ((double) i * (i-1)) / ((double) j * (j-1)); // dp[A][B][C] = 1; // rep(N){ // rep(i,1,A+1) rep(j,1,B+1) rep(k,1,C+1){ // tmp = dp[i][j][k]; // dp[i-1][j][k] += tmp * p[i][i+j+k]; // dp[i][j-1][k] += tmp * p[j][i+j+k]; // dp[i][j][k-1] += tmp * p[k][i+j+k]; // dp[i][j][k] -= tmp * (p[i][i+j+k] + p[j][i+j+k] + p[k][i+j+k]); // } // } // rep(i,1,A+1) rep(j,1,B+1) rep(k,1,C+1){ // res[0] += (A-i) * dp[i][j][k]; // res[1] += (B-j) * dp[i][j][k]; // res[2] += (C-k) * dp[i][j][k]; // } // wt(res(3)); // }