#include using namespace std; using ll = long long; #define TYPE_OF( VAR ) remove_const::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 QUIT return 0 #define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT #define POWER( ANSWER , ARGUMENT , EXPONENT , MODULO ) \ TYPE_OF( ARGUMENT ) ANSWER = 1; \ { \ TYPE_OF( ARGUMENT ) ARGUMENT_FOR_SQUARE_FOR_POWER = ( ARGUMENT ); \ TYPE_OF( EXPONENT ) EXPONENT_FOR_SQUARE_FOR_POWER = ( EXPONENT ); \ while( EXPONENT_FOR_SQUARE_FOR_POWER != 0 ){ \ if( EXPONENT_FOR_SQUARE_FOR_POWER % 2 == 1 ){ \ ANSWER = ( ANSWER * ARGUMENT_FOR_SQUARE_FOR_POWER ) % MODULO; \ } \ ARGUMENT_FOR_SQUARE_FOR_POWER = ( ARGUMENT_FOR_SQUARE_FOR_POWER * ARGUMENT_FOR_SQUARE_FOR_POWER ) % MODULO; \ EXPONENT_FOR_SQUARE_FOR_POWER /= 2; \ } \ } \ int main() { UNTIE; constexpr const ll P = 998244353; constexpr const ll bound = 1000000000000000000; CIN_ASSERT( N , 1 , bound ); CIN_ASSERT( M , 1 , bound ); CIN_ASSERT( K , 1 , bound ); // c[n,m,k] := (1からmまでの整数からなる長さnの列でmax - min < kであるものの総数) // = max( 0 , m - k ) * ( k ^ n - ( k - 1 ) ^ n ) + min( m , k ) ^ n // = m > k ? ( m - k + 1 ) * k ^ n - ( m - k ) * ( k - 1 ) ^ n : m ^ n N *= 2; if( M <= K ){ POWER( answer , M , N , P ); RETURN( answer ); } M = ( M - K ) % P; K %= P; POWER( K_power , K , N , P ); POWER( K_minus_power , K == 0 ? P - 1 : K - 1 , N , P ); RETURN( ( ( M + 1 ) * K_power + P - ( ( M * K_minus_power ) % P ) ) % P ); }