結果
問題 | No.2141 Enumeratest |
ユーザー | 👑 p-adic |
提出日時 | 2022-10-26 18:31:09 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 2,245 bytes |
コンパイル時間 | 2,222 ms |
コンパイル使用メモリ | 201,492 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-10-09 21:43:50 |
合計ジャッジ時間 | 4,585 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
11,264 KB |
testcase_01 | AC | 24 ms
11,248 KB |
testcase_02 | AC | 27 ms
11,260 KB |
testcase_03 | AC | 30 ms
11,380 KB |
testcase_04 | AC | 32 ms
11,264 KB |
testcase_05 | AC | 26 ms
11,392 KB |
testcase_06 | AC | 27 ms
11,276 KB |
testcase_07 | AC | 28 ms
11,136 KB |
testcase_08 | AC | 27 ms
11,364 KB |
testcase_09 | AC | 29 ms
11,264 KB |
testcase_10 | AC | 28 ms
11,284 KB |
testcase_11 | AC | 29 ms
11,344 KB |
testcase_12 | AC | 24 ms
11,264 KB |
testcase_13 | AC | 26 ms
11,236 KB |
testcase_14 | AC | 29 ms
11,156 KB |
testcase_15 | AC | 29 ms
11,244 KB |
testcase_16 | AC | 33 ms
11,384 KB |
testcase_17 | AC | 28 ms
11,264 KB |
testcase_18 | AC | 28 ms
11,392 KB |
testcase_19 | AC | 28 ms
11,232 KB |
testcase_20 | AC | 28 ms
11,392 KB |
testcase_21 | AC | 26 ms
11,212 KB |
testcase_22 | AC | 26 ms
11,264 KB |
testcase_23 | AC | 24 ms
11,264 KB |
testcase_24 | AC | 28 ms
11,136 KB |
testcase_25 | AC | 27 ms
11,392 KB |
testcase_26 | AC | 29 ms
11,264 KB |
testcase_27 | AC | 27 ms
11,364 KB |
testcase_28 | AC | 29 ms
11,260 KB |
testcase_29 | AC | 27 ms
11,264 KB |
testcase_30 | AC | 30 ms
11,264 KB |
testcase_31 | AC | 30 ms
11,264 KB |
testcase_32 | AC | 30 ms
11,344 KB |
testcase_33 | AC | 26 ms
11,240 KB |
testcase_34 | AC | 28 ms
11,312 KB |
testcase_35 | AC | 26 ms
11,136 KB |
testcase_36 | AC | 25 ms
11,316 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; #define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type #define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) #define CIN( LL , A ) LL A; cin >> A #define ASSERT( A , MIN , MAX ) assert( MIN <= A && A <= MAX ) #define CIN_ASSERT( A , MIN , MAX ) CIN( TYPE_OF( MAX ) , A ); ASSERT( A , MIN , MAX ) #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( TYPE_OF( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define FOREQ( VAR , INITIAL , FINAL ) for( TYPE_OF( FINAL ) VAR = INITIAL ; VAR <= FINAL ; VAR ++ ) #define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) #define QUIT return 0 #define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT #define POWER( ANSWER , VAR , EXPONENT_REF , MODULO ) \ TYPE_OF( VAR ) ANSWER = 1; \ { \ TYPE_OF( VAR ) VARIABLE_FOR_SQUARE_FOR_POWER = VAR; \ while( EXPONENT_REF != 0 ){ \ if( EXPONENT_REF % 2 == 1 ){ \ ANSWER = ( ANSWER * VARIABLE_FOR_SQUARE_FOR_POWER ) % MODULO; \ } \ VARIABLE_FOR_SQUARE_FOR_POWER = ( VARIABLE_FOR_SQUARE_FOR_POWER * VARIABLE_FOR_SQUARE_FOR_POWER ) % MODULO; \ EXPONENT_REF /= 2; \ } \ } \ #define CHECK_REDUNDANT_INPUT string VARIABLE_FOR_CHECK_REDUNDANT_INPUT = ""; cin >> VARIABLE_FOR_CHECK_REDUNDANT_INPUT; assert( VARIABLE_FOR_CHECK_REDUNDANT_INPUT == "" ); assert( ! cin ); int main() { constexpr const ll bound = 1000000; CIN_ASSERT( N , 1 , bound ); CIN_ASSERT( M , 1 , bound ); CHECK_REDUNDANT_INPUT; ll a = M / N; ll b = M % N; constexpr const ll P = 998244353; ll inv[bound+1]; inv[1] = 1; FOREQ( i , 2 , bound ){ inv[i] = P - ( ( inv[ P % i ] * ( P / i ) ) % P ); } ll answer = 1; FOREQ( i , a + 1 , M ){ answer = ( answer * i ) % P; } ll prod_inv = 1; FOREQ( i , 2 , a ){ prod_inv = ( prod_inv * inv[i] ) % P; } N--; POWER( prod_inv_power , prod_inv , N , P ); answer = ( answer * prod_inv_power ) % P; ll& inv_a_plus = inv[a + 1]; POWER( inv_a_plus_power , inv_a_plus , b , P ); answer = ( answer * inv_a_plus_power ) % P; RETURN( answer ); }