結果

問題 No.2262 Fractions
ユーザー 👑 p-adic
提出日時 2023-06-30 20:16:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 62,060 bytes
コンパイル時間 12,417 ms
コンパイル使用メモリ 239,424 KB
最終ジャッジ日時 2025-02-15 03:27:22
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from main.cpp:24:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:181:14: note: called from here
  181 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ); signal( SIGABRT , &AlertAbort )
#define DEXPR( LL , BOUND , VALUE , DEBUG_VALUE ) CEXPR( LL , BOUND , DEBUG_VALUE )
#define CERR( ANSWER ) cerr << ANSWER << endl;
#define COUT( ANSWER ) cout << ANSWER << endl
#define ASSERT( A , MIN , MAX ) CERR( "ASSERT " << ( MIN ) << ( ( MIN ) <= A ? "<=" : ">" ) << A << ( A <= ( MAX ) ? "<=" : ">" ) << (
      MAX ) ); assert( ( MIN ) <= A && A <= ( MAX ) )
#define LIBRARY_SEARCH if( LibrarySearch() != 0 ){ QUIT; };
#define START_WATCH( PROCESS_NAME ) StartWatch( PROCESS_NAME )
#define STOP_WATCH( HOW_MANY_TIMES ) StopWatch( HOW_MANY_TIMES )
#else
#pragma GCC optimize ( "O3" )
#pragma GCC optimize( "unroll-loops" )
#pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" )
#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr )
#define DEXPR( LL , BOUND , VALUE , DEBUG_VALUE ) CEXPR( LL , BOUND , VALUE )
#define CERR( ANSWER )
#define COUT( ANSWER ) cout << ANSWER << "\n"
#define ASSERT( A , MIN , MAX ) assert( ( MIN ) <= A && A <= ( MAX ) )
#define LIBRARY_SEARCH
#define START_WATCH( PROCESS_NAME )
#define STOP_WATCH( HOW_MANY_TIMES )
#endif
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#define ATT __attribute__( ( target( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" ) ) )
#define TYPE_OF( VAR ) decay_t<decltype( VAR )>
#define CEXPR( LL , BOUND , VALUE ) constexpr LL BOUND = VALUE
#define CIN( LL , A ) LL A; cin >> A
#define CIN_ASSERT( A , MIN , MAX ) CIN( TYPE_OF( MAX ) , A ); ASSERT( A , MIN , MAX )
#define SET_ASSERT( A , MIN , MAX ) cin >> A; ASSERT( A , MIN , MAX )
#define GETLINE( A ) string A; getline( cin , A )
#define GETLINE_SEPARATE( A , SEPARATOR ) string A; getline( cin , A , SEPARATOR )
#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 FOREQINV( VAR , INITIAL , FINAL ) for( TYPE_OF( INITIAL ) VAR = INITIAL ; VAR >= FINAL ; VAR -- )
#define AUTO_ITR( ARRAY ) auto itr_ ## ARRAY = ARRAY .begin() , end_ ## ARRAY = ARRAY .end()
#define FOR_ITR( ARRAY ) for( AUTO_ITR( ARRAY ) , itr = itr_ ## ARRAY ; itr_ ## ARRAY != end_ ## ARRAY ; itr_ ## ARRAY ++ , itr++ )
#define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT_ ## HOW_MANY_TIMES , 0 , HOW_MANY_TIMES )
#define QUIT return 0
#define SET_PRECISION( DECIMAL_DIGITS ) cout << fixed << setprecision( DECIMAL_DIGITS_ )
#define RETURN( ANSWER ) COUT( ( ANSWER ) ); QUIT
#ifdef DEBUG
inline void AlertAbort( int n ) { CERR(
      "abortassert" ); }
void StartWatch( const string& process_name = "nothing" );
void StopWatch( const int& how_many_times = 1 );
#endif
template <typename T> inline T Absolute( const T& a ){ return a > 0 ? a : -a; }
template <typename T> inline T Residue( const T& a , const T& p ){ return a >= 0 ? a % p : ( a % p ) + p; }
#define POWER( ANSWER , ARGUMENT , EXPONENT ) \
static_assert( ! is_same<TYPE_OF( ARGUMENT ),int>::value && ! is_same<TYPE_OF( ARGUMENT ),uint>::value ); \
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 *= ARGUMENT_FOR_SQUARE_FOR_POWER; \
} \
ARGUMENT_FOR_SQUARE_FOR_POWER *= ARGUMENT_FOR_SQUARE_FOR_POWER; \
EXPONENT_FOR_SQUARE_FOR_POWER /= 2; \
} \
} \
#define POWER_MOD( ANSWER , ARGUMENT , EXPONENT , MODULO ) \
ll ANSWER{ 1 }; \
{ \
ll ARGUMENT_FOR_SQUARE_FOR_POWER = ( MODULO + ( ( ARGUMENT ) % MODULO ) ) % MODULO; \
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; \
} \
} \
#define FACTORIAL_MOD( ANSWER , ANSWER_INV , INVERSE , MAX_INDEX , CONSTEXPR_LENGTH , MODULO ) \
static ll ANSWER[CONSTEXPR_LENGTH]; \
static ll ANSWER_INV[CONSTEXPR_LENGTH]; \
static ll INVERSE[CONSTEXPR_LENGTH]; \
{ \
ll VARIABLE_FOR_PRODUCT_FOR_FACTORIAL = 1; \
ANSWER[0] = VARIABLE_FOR_PRODUCT_FOR_FACTORIAL; \
FOREQ( i , 1 , MAX_INDEX ){ \
ANSWER[i] = ( VARIABLE_FOR_PRODUCT_FOR_FACTORIAL *= i ) %= MODULO; \
} \
ANSWER_INV[0] = ANSWER_INV[1] = INVERSE[1] = VARIABLE_FOR_PRODUCT_FOR_FACTORIAL = 1; \
FOREQ( i , 2 , MAX_INDEX ){ \
ANSWER_INV[i] = ( VARIABLE_FOR_PRODUCT_FOR_FACTORIAL *= INVERSE[i] = MODULO - ( ( ( MODULO / i ) * INVERSE[MODULO % i] ) % MODULO ) ) %=
          MODULO; \
} \
} \
//
// EXPRESSIONANSWER調EXPRESSION >= TARGET
#define BS( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , DESIRED_INEQUALITY , TARGET , INEQUALITY_FOR_CHECK , UPDATE_U , UPDATE_L , UPDATE_ANSWER ) \
static_assert( ! is_same<TYPE_OF( TARGET ),uint>::value && ! is_same<TYPE_OF( TARGET ),ull>::value ); \
ll ANSWER = MINIMUM; \
if( MINIMUM <= MAXIMUM ){ \
ll VARIABLE_FOR_BINARY_SEARCH_L = MINIMUM; \
ll VARIABLE_FOR_BINARY_SEARCH_U = MAXIMUM; \
ANSWER = ( VARIABLE_FOR_BINARY_SEARCH_L + VARIABLE_FOR_BINARY_SEARCH_U ) / 2; \
ll VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH; \
while( VARIABLE_FOR_BINARY_SEARCH_L != VARIABLE_FOR_BINARY_SEARCH_U ){ \
VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH = ( EXPRESSION ) - ( TARGET ); \
CERR( " " << VARIABLE_FOR_BINARY_SEARCH_L << "<=" << ANSWER << "<=" << VARIABLE_FOR_BINARY_SEARCH_U << ":" << EXPRESSION << "-" <<
          TARGET << "=" << VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH ); \
if( VARIABLE_FOR_DIFFERENCE_FOR_BINARY_SEARCH INEQUALITY_FOR_CHECK 0 ){ \
VARIABLE_FOR_BINARY_SEARCH_U = UPDATE_U; \
} else { \
VARIABLE_FOR_BINARY_SEARCH_L = UPDATE_L; \
} \
ANSWER = UPDATE_ANSWER; \
} \
CERR( " " << VARIABLE_FOR_BINARY_SEARCH_L << "<=" << ANSWER << "<=" << VARIABLE_FOR_BINARY_SEARCH_U << ":" << EXPRESSION << (
        EXPRESSION > TARGET ? ">" : EXPRESSION < TARGET ? "<" : "=" ) << TARGET ); \
CERR( ( EXPRESSION DESIRED_INEQUALITY TARGET ? "" : "" ) ); \
assert( EXPRESSION DESIRED_INEQUALITY TARGET ); \
} else { \
CERR( " " << MINIMUM << ">" << MAXIMUM ); \
assert( MINIMUM <= MAXIMUM ); \
} \
// 調EXPRESSION >= TARGET
#define BS1( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , TARGET ) \
BS( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , >= , TARGET , >= , ANSWER , ANSWER + 1 , ( VARIABLE_FOR_BINARY_SEARCH_L +
      VARIABLE_FOR_BINARY_SEARCH_U ) / 2 ) \
// 調EXPRESSION <= TARGET
#define BS2( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , TARGET ) \
BS( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , <= , TARGET , > , ANSWER - 1 , ANSWER , ( VARIABLE_FOR_BINARY_SEARCH_L + 1 +
      VARIABLE_FOR_BINARY_SEARCH_U ) / 2 ) \
// 調EXPRESSION >= TARGET
#define BS3( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , TARGET ) \
BS( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , >= , TARGET , < , ANSWER - 1 , ANSWER , ( VARIABLE_FOR_BINARY_SEARCH_L + 1 +
      VARIABLE_FOR_BINARY_SEARCH_U ) / 2 ) \
// 調EXPRESSION <= TARGET
#define BS4( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , TARGET ) \
BS( ANSWER , MINIMUM , MAXIMUM , EXPRESSION , <= , TARGET , <= , ANSWER , ANSWER + 1 , ( VARIABLE_FOR_BINARY_SEARCH_L +
      VARIABLE_FOR_BINARY_SEARCH_U ) / 2 ) \
//
#define TE template
#define TY typename
#define US using
#define ST static
#define IN inline
#define CL class
#define PU public
#define OP operator
#define CE constexpr
#define CO const
#define NE noexcept
#define RE return
#define WH while
#define VO void
#define VE vector
#define LI list
#define BE begin
#define EN end
#define SZ size
#define MO move
#define TH this
#define CRI CO int&
#define CRUI CO uint&
#define CRL CO ll&
#define ASK_DETAILS( ... ) \
CERR( "" ); \
problems = { __VA_ARGS__ }; \
problems_size = problems.size(); \
FOR( i , 0 , problems_size ){ \
CERR( i << ": " << problems[i] ); \
} \
cin >> num; \
CERR( "" ); \
num_temp = 0; \
if( num < 0 || num >= problems_size ){ \
CERR( "" << problems_size - 1 << "" ); \
CERR( "" ); \
CERR( "" ); \
return -1; \
} \
int LibrarySearch( int num = -1 )
{
vector<string> problems{};
int problems_size = 13;
int num_temp = 0;
string reply{};
if( num == -1 ){
CERR( "[y/n]" );
cin >> reply;
if( reply == "n" ){
CERR( "" );
CERR( "" );
return 0;
} else if( reply != "y" ){
CERR( "y/n" );
CERR( "" );
CERR( "" );
return -1;
}
CERR( "" );
CERR( "" );
ASK_DETAILS(
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
"" ,
""
);
} else {
CERR( "" );
}
CEXPR( int , num_graph , 5 );
CEXPR( int , num_subsequence_sum , 6 );
CEXPR( int , num_game , 8 );
if( num == num_temp++ ){
CERR( "[y/n]" );
cin >> reply;
CERR( "" );
if( reply == "y" ){
CERR( "OEIS" );
CERR( "https://oeis.org/?language=japanese" );
CERR( "" );
CERR( "" );
CERR( "- 調" );
CERR( "- p使" );
CERR( "- pp" );
CERR( " " );
CERR( "" );
} else if( reply == "n" ){
ASK_DETAILS(
"" ,
"" ,
"" ,
""
);
if( num == num_temp++ ){
CERR( "" );
CERR( "- 調" );
CERR( "- " );
CERR( "- " );
CERR( "" );
CERR( "" );
CERR( "" );
CERR( "- " );
CERR( "- " );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "- " );
CERR( "- " );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "- " );
CERR( "- " );
CERR( "- " );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "" );
}
} else {
CERR( "y/n" );
CERR( "" );
CERR( "" );
return -1;
}
CERR( "" );
CERR( "" );
CERR( "" );
} else if( num == num_temp++ ){
ASK_DETAILS(
"" ,
"" ,
"" ,
"" ,
""
);
if( num == num_temp++ ){
ASK_DETAILS(
"+使" ,
"使" ,
"*使" ,
"*使" ,
"(*,\\cdot)使" ,
"(+,\\cdot)使" ,
"max使"
);
if( num == num_temp++ ){
CERR( "- BIT" );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\AffineSpace\\BIT\\Template" );
CERR( "- " );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\AffineSpace\\SqrtDecomposition\\Template" );
CERR( "- " );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\Tree\\DifferenceSeqeuence" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "- BIT" );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\AffineSpace\\BIT\\IntervalMax\\Template" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "- BIT" );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\AffineSpace\\BIT\\Template\\Monoid" );
CERR( "- " );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\AffineSpace\\SqrtDecomposition\\Template\\Monoid" );
CERR( "- " );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\AffineSpace\\SegmentTree" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "- " );
CERR( " \\Mathematics\\Function\\Encoder" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "- " );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\AffineSpace\\SqrtDecomposition\\Template\\Dual" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "- " );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\AffineSpace\\SqrtDecomposition\\Template\\LazyEvaluation" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "max" );
CERR( "調max調" );
CERR( "" );
CERR( "" );
CERR( "maxmax調" );
CERR( "maxmax" );
CERR( "調" );
CERR( "調" );
CERR( "" );
CERR( "max{0,1}" );
CERR( "使" );
CERR( "" );
CERR( "" );
CERR( "" );
CERR( "B_qmax(A_i,B_q)" );
CERR( "- A'={(A_i,i)|i}O(N log N)" );
CERR( "- (B_q,q)_qB'O(Q log Q)" );
CERR( "- NC=(0,...,0)O(N)" );
CERR( "B'(B_q,q)" );
CERR( "A'A_i<B_qi" );
CERR( "- A'(A_i,i)O(N)" );
CERR( "- A_i0O(N log N)" );
CERR( "- C_i1O(log N)" );
CERR( "- A+C×B_qO(log N)" );
CERR( "O((N + Q)log N + Q log Q)" );
}
} else if( num == num_temp++ ){
CERR( "fx" );
CERR( "- ixX(i)" );
CERR( "- ixi+1xdX(i)" );
CERR( "" );
CERR( "- O(sum_i X(i) dX(i))fxO(1)ix" );
CERR( "- O(N log_2 X(N))" );
CERR( " - fxO(N)x調x" );
CERR( " - fxO(N/x)x" );
CERR( "- O(N log_2 N)xfxO(log_2 N)" );
CERR( " x" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "" );
CERR( "- " );
CERR( " " );
CERR( "- " );
CERR( " " );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "gcdmax" );
CERR( "" );
} else if( num == num_temp++ ){
return LibrarySearch( num = num_subsequence_sum );
}
} else if( num == num_temp++ ){
ASK_DETAILS(
"" ,
""
);
if( num == num_temp++ ){
CERR( "" );
CERR( "- " );
CERR( "- " );
CERR( " - O(N)" );
CERR( " - O(N)" );
CERR( "- " );
CERR( " \\Utility\\String\\RollingHash" );
CERR( "- Z" );
CERR( " https://qiita.com/Pro_ktmr/items/16904c9570aa0953bf05" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "" );
CERR( "- O(N^2)" );
CERR( "- O(N^2)Manacher" );
CERR( " https://snuke.hatenablog.com/entry/2014/12/02/235837" );
CERR( "" );
}
} else if( num == num_temp++ ){
CERR( "" );
CERR( "" );
CERR( "- O(N^3)" );
CERR( "- O(N 2^N)" );
CERR( "" );
CERR( "" );
CERR( "" );
CERR( "- O(N^2)" );
CERR( "- O(N log_2 N)BIT" );
CERR( " \\Mathematics\\Combinatorial\\Permutation" );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\AffineSpace\\BIT" );
CERR( "" );
CERR( "" );
CERR( "" );
CERR( "i<j" );
CERR( "" );
CERR( "" );
} else if( num == num_temp++ ){
ASK_DETAILS(
"" ,
"" ,
""
);
if( num == num_temp++ ){
CERR( "" );
return LibrarySearch( num = num_graph );
} else if( num == num_temp++ ){
CERR( "" );
CERR( "- 調" );
CERR( "- " );
CERR( "- " );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "" );
CERR( "- O(HW)" );
CERR( "- O(HW)" );
CERR( "" );
CERR( "" );
CERR( "" );
CERR( "- " );
CERR( "- " );
CERR( "" );
}
} else if( num == num_temp++ ){
ASK_DETAILS(
"" ,
"" ,
"" ,
""
);
if( num == num_temp++ ){
CERR( "" );
CERR( "" );
CERR( "- BFSDijkstra" );
CERR( " \\Utility\\Search\\BreadthFirst" );
CERR( " \\Utility\\Search\\Dijkstra" );
CERR( "- " );
CERR( " - O(V^3)FloydWarshall" );
CERR( " \\Utility\\Search\\FloydWarshall" );
CERR( " - maxO(E(log_2 E + α(V)))UnionFind" );
CERR( " \\Utility\\VLTree\\UnionFindForest" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "HeldKarp" );
} else if( num == num_temp++ ){
CERR( "" );
CERR( "\\Utility\\Search\\DepthFirst" );
CERR( "\\Utility\\VLTree" );
} else if( num == num_temp++ ){
CERR( "- 0UnionFind" );
CERR( " \\Utility\\VLTree\\UnionFindForest" );
CERR( "- " );
CERR( " \\Utility\\Search\\DepthFirst" );
CERR( "- " );
CERR( "" );
}
} else if( num == num_temp++ ){
ASK_DETAILS(
"" ,
""
);
if( num == num_temp++ ){
CERR( "NWV" );
CERR( "- B=∞" );
CERR( "- B<∞O(2^N)" );
CERR( "- B<∞O(2^{N/2} N)" );
CERR( "- B<∞O(NV)[B-V,B+V]" );
CERR( " " );
CERR( " https://stackoverflow.com/a/18949218" );
CERR( "- W10^5O((N+W)log_2 W)" );
CERR( " " );
CERR( " \\Mathematics\\Polynomial" );
} else if( num == num_temp++ ){
CERR( "NW" );
CERR( "- O(2^N)" );
CERR( "- O(2^N)" );
CERR( "- O(2^{N/2}N)" );
CERR( " " );
CERR( "- W10^5O((N+W)log_2 W)" );
CERR( " " );
CERR( " \\Mathematics\\Polynomial" );
}
CERR( "" );
} else if( num == num_temp++ ){
CERR( "" );
CERR( "- " );
CERR( "- " );
CERR( "- " );
CERR( "" );
CERR( "" );
CERR( "" );
CERR( "- " );
CERR( "- " );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "" );
CERR( "- " );
CERR( " \\Mathematics\\SetTheory\\DirectProduct\\AffineSpace" );
CERR( "- UnionFind" );
CERR( " \\Utility\\VLTree\\UnionFindForest" );
CERR( "" );
} else if( num == num_temp++ ){
ASK_DETAILS(
"" ,
""
);
if( num == num_temp++ ){
CERR( "" );
} else if( num == num_temp++ ){
CERR( "" );
return LibrarySearch( num = num_graph );
}
} else if( num == num_temp++ ){
ASK_DETAILS(
"" ,
""
);
if( num == num_temp++ ){
CERR( "NTK" );
CERR( "- O((N + T)log_2 K)" );
CERR( " \\Mathematics\\Function\\Iteration\\Doubling" );
CERR( "- O(TN)" );
CERR( " \\Mathematics\\Function\\Iteration\\LoopDetection" );
CERR( "- O(N)" );
CERR( "" );
} else if( num == num_temp++ ){
CERR( "" );
return LibrarySearch( num = num_graph );
}
} else if( num == num_temp++ ){
ASK_DETAILS(
"" ,
"" ,
""
);
if( num == num_temp++ ){
CERR( "p" );
} else if( num == num_temp++ ){
CERR( "" );
return LibrarySearch( num = num_graph );
} else if( num == num_temp++ ){
CERR( "" );
return LibrarySearch( num = num_game );
}
}
CERR( "" );
CERR( "" );
CERR( "" );
return -1;
}
TE <TY INT,INT val_limit,int LE_max = val_limit>CL PrimeEnumeration{PU:INT m_val[LE_max];int m_LE;CE PrimeEnumeration();};TE <TY INT,INT val_limit
    ,int LE_max>CE PrimeEnumeration<INT,val_limit,LE_max>::PrimeEnumeration():m_val(),m_LE(0){bool is_comp[val_limit] ={};for(INT i = 2;i <
    val_limit;i++){if(is_comp[i] == false){INT j = i;WH((j += i) < val_limit){is_comp[j] = true;}m_val[m_LE++] = i;if(m_LE >= LE_max){break;}}}}TE
    <TY INT,INT val_limit,int LE_max>VO SetPrimeFactorisation(CO PrimeEnumeration<INT,val_limit,LE_max>& prime,CO INT& n,VE<INT>& P,VE<INT>& EX){INT
    n_copy = n;int i = 0;WH(i < prime.m_LE){CO INT& p = prime.m_val[i];if(p * p > n_copy){break;}if(n_copy % p == 0){P.push_back(p);EX.push_back(1
    );INT& EX_back = EX.back();n_copy /= p;WH(n_copy % p == 0){EX_back++;n_copy /= p;}}i++;}if(n_copy != 1){P.push_back(n_copy);EX.push_back(1);}RE
    ;}
#define EULER_FUNCTION EX.clear();INT AN = n;CO INT SZ = P.SZ();for(INT i = 0;i < SZ;i++){AN -= AN / P[i];}RE AN;
TE <TY INT,INT val_limit,int LE_max>INT EulerFunction(CO PrimeEnumeration<INT,val_limit,LE_max>& prime,CO INT& n,VE<INT>& P,VE<INT>& EX
    ){SetPrimeFactorisation(prime,n,P,EX);EULER_FUNCTION;}TE <TY INT,INT val_limit,int LE_max>IN INT EulerFunction(CO PrimeEnumeration<INT,val_limit
    ,LE_max>& prime,CO INT& n){VE<INT> P{};VE<INT> EX{};RE EulerFunction(prime,n,P,EX);}TE <TY INT,INT val_limit,int LE_max,int SZ,TY INT2>VO
    MemoriseEulerFunction(CO PrimeEnumeration<INT,val_limit,LE_max>& prime,INT2(&memory)[SZ]){ST INT quotient[SZ];for(int n = 1;n < SZ;n
    ++){memory[n] = quotient[n] = n;}for(int i = 0;i < prime.m_LE;i++){CO INT& p_i = prime.m_val[i];int n = 0;WH((n += p_i)< SZ){INT2& memory_n =
    memory[n];INT& quotient_n = quotient[n];memory_n -= memory_n / p_i;WH((quotient_n /= p_i)% p_i == 0){}}}for(int n = val_limit;n < SZ;n++){CO
    INT& quotient_n = quotient[n];if(quotient_n != 1){INT2& memory_n = memory[n];memory_n -= memory_n / quotient_n;}}RE;}
TE <int SZ_max> VO MemoriseEnumerateDivisor(LI<int>(&memory)[SZ_max])NE{for(int d = 1;d < SZ_max;d++){int n = 0;WH((n += d)< SZ_max){memory[n]
    .push_back(d);}}RE;}
TE <TY INT,INT val_limit,int LE_max>int MoeviusFunction(CO PrimeEnumeration<INT,val_limit,LE_max>& prime,INT n)NE{int AN = 1;int i = 0;WH(i < prime
    .m_LE && n > 1){CRI p = prime.m_val[i++];if(n % p == 0){if((n /= p)% p == 0){RE 0;}AN *= -1;}}RE n == 1?AN:AN *= -1;}
// #define DEFINITION_OF_GET_FOR_ZETA_TRANSFORM( MU ) \
// list<T> sub = Sub( t ); \
// sub.push_front( t ); \
// U answer = Zero(); \
// \
// while( ! sub.empty() ){ \
// \
// const T& t_sub = sub.front(); \
// answer = Sum( answer , Prod( m_val[e_inv( t_sub )] , MU( t_sub , t ) ) ); \
// sub.pop_front(); \
// \
// } \
// \
// return answer; \
// #define DEFINITION_OF_INVERSE_IMAGE_SUM_FOR_ZETA_TRANSFORM( MU ) \
// const T t = f_inv_max( s ); \
// list<S> sub = r( s ); \
// U answer = Zero(); \
// \
// while( ! sub.empty() ){ \
// \
// const T& t_sub = f_inv_max( sub.front() ); \
// answer = Sum( answer , Prod( m_val[e_inv( t_sub )] , MU( t_sub , t ) ) ); \
// sub.pop_front(); \
// \
// } \
// \
// return answer; \
// template <typename T , typename U , int size_max>
// class ZetaTransformBody
// {
// private:
// int m_length;
// map<T,int> m_memory;
// vector<T> m_memory_inv;
// protected:
// int m_size;
// // U m_val[size_max];
// vector<U> m_val;
// public:
// //
// inline ZetaTransformBody( const int& size = 0 );
// inline void Add( const T& t , const U& u );
// inline void AddAll( const U& u );
// inline ZetaTransformBody<T,U,size_max>& operator+=( const ZetaTransformBody<T,U,size_max>& a );
// inline void MultiplyAll( const U& u );
// inline ZetaTransformBody<T,U,size_max>& operator*=( const ZetaTransformBody<T,U,size_max>& a );
// // 使
// // 使
// inline U Get( const T& t );
// // mu
// template <int mu(const T&,const T&)> inline U Get( const T& t );
// inline const U& InitialSegmentSum( const T& t );
// // f_inv_maxr(s)T->S
// // (1) S
// // (2) r(s)
// // (3) sr(s)
// // (4) f_inv_max(s)TRff_RR->r(s)
// // (5) r(s)tf_inv_max(t)f_R^{-1}(t)
// // f
// // f( t ) = sRt
// template <typename S , T f_inv_max(const S&) , list<S> r(const S&)> inline U InverseImageSum( const S& s );
// template <typename S , T f_inv_max(const S&) , list<S> r(const S&) , int mu(const T&,const T&)> inline U InverseImageSum( const S& s );
// // f( t ) <= sRtr使r
// template <typename S , T f_inv_max(const S&)> inline const U& InitialSegmentInverseImageSum( const S& s );
// virtual T e( const int& i );
// virtual int e_inv( const T& t );
// private:
// virtual const U& Zero() const = 0;
// virtual U Sum( const U& u0 , const U& u1 ) const = 0;
// virtual U Prod( const U& u0 , const U& u1 ) const = 0;
// virtual list<T> Sub( const T& t ) const = 0;
// virtual list<T> Sup( const T& t ) const = 0;
// virtual int Moevius( const T& t0 , const T& t1 ) = 0;
// };
// template <typename T , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max>
// class SemiRingForZetaTransform :
// virtual public ZetaTransformBody<T,U,size_max>
// {
// public:
// inline SemiRingForZetaTransform( const int& dummy );
// private:
// inline const U& Zero() const;
// inline U Sum( const U& u0 , const U& u1 ) const;
// inline U Prod( const U& u0 , const U& u1 ) const;
// };
// template <typename T , list<T> E(const T&) , list<T> E_inv(const T&) , typename U , int size_max>
// class PartiallyOrderedSetForZetaTransform :
// virtual public ZetaTransformBody<T,U,size_max>
// {
// private:
// map<int,map<int,int> > m_moevius;
// inline list<T> Sub( const T& t ) const;
// inline list<T> Sup( const T& t ) const;
// // 使
// inline int Moevius( const T& t0 , const T& t1 );
// };
// template <typename U , int size_max>
// class EnumerationForZetaTransform :
// virtual public ZetaTransformBody<int,U,size_max>
// {
// private:
// inline int e( const int& i );
// inline int e_inv( const int& t );
// };
// //
// // (1) Eint<E_inv(int,>)
// //
// // 0O(size_max)
// // O()
// // O([t,∞))
// // O(size)
// // O(size)
// // O(size)
// // (int,<)joinO(size)
// // O((-∞,t]×)
// // O(1)
// // O((-∞,f_inv_max(r_max)]×)
// // O(1)
// template <list<int> E(const int&) , list<int> E_inv(const int&) , int size_max>
// class ZetaTransform :
// public PartiallyOrderedSetForZetaTransform<int,E,E_inv,ll,size_max> ,
// public EnumerationForZetaTransform<ll,size_max>
// {
// public:
// inline ZetaTransform( const int& size );
// // inline ZetaTransform( const int& size , const ll ( &a )[size_max] );
// inline ZetaTransform( const int& size , const vector<ll>&a );
// private:
// inline const ll& Zero() const;
// inline ll Sum( const ll& u0 , const ll& u1 ) const;
// inline ll Prod( const ll& u0 , const ll& u1 ) const;
// };
// //
// // (1) 2^digit <= size_max
// // (2) (U,a_U:U^2->U,z_U:1->U,m_U:U^2->U)
// //
// // z_U()O(size_max)
// // O(digit 2^digit)使
// // O(2^digit)使
// // O(2^digit)使
// // O(2^digit)使
// // O(2^digit)使
// // O(2^digit)使
// // O(2^digit)使
// // O(digit 2^digit)使
// // O(1)使
// // O((-∞,f_inv_max(r_max)])使
// // O(1)使
// template <typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max>
// class FastZetaTransform :
// public SemiRingForZetaTransform<int,U,a_U,z_U,m_U,size_max> ,
// public EnumerationForZetaTransform<U,size_max>
// {
// private:
// int m_digit;
// public:
// inline FastZetaTransform( const int& digit );
// inline FastZetaTransform( const int& digit , const U ( &a )[size_max] );
// inline FastZetaTransform<U,a_U,z_U,m_U,size_max>& operator+=( const FastZetaTransform<U,a_U,z_U,m_U,size_max>& a );
// inline FastZetaTransform<U,a_U,z_U,m_U,size_max>& operator*=( const FastZetaTransform<U,a_U,z_U,m_U,size_max>& a );
// inline void FastMoeviusTransform( U ( &a )[size_max] );
// private:
// inline list<int> Sub( const int& t ) const;
// inline list<int> Sup( const int& t ) const;
// inline int Moevius( const int& t0 , const int& t1 );
// };
// //
// // (1) ET<E_inv(T,>)
// // (2) (U,a_U:U^2->U,z_U:1->U,m_U:U^2->U)
// //
// // z_U()O(size_max)
// // O([t,∞)×log_2(size))使
// // O(size)使
// // O(size)使
// // O(size)使
// // (T,<)joinO(size)使
// // O((-∞,t]××log_2(size))使
// // O(log_2(size))使
// // O((-∞,f_inv_max(r_max)]××log_2(size))使
// // O(log_2(size))使
// template <typename T , list<T> E(const T&) , list<T> E_inv(const T&) , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&
    ,const U&) , int size_max>
// class MemorisationZetaTransform :
// public SemiRingForZetaTransform<T,U,a_U,z_U,m_U,size_max> ,
// public PartiallyOrderedSetForZetaTransform<T,E,E_inv,U,size_max>
// {
// public:
// inline MemorisationZetaTransform( const int& size );
// };
// //
// // (1) ET<E_inv(T,>)
// // (2) (U,a_U:U^2->U,z_U:1->U,m_U:U^2->U)
// // (3) enum_T:int->Tenum_T_inv:int->T
// //
// // z_U()O(size_max)
// // O([t,∞))使
// // O(size)使
// // O(size)使
// // O(size)使
// // (T,<)joinO(size)使
// // O((-∞,t]×)使
// // O(1)使
// // O((-∞,f_inv_max(r_max)]×)使
// // O(1)使
// template <typename T , list<T> E(const T&) , list<T> E_inv(const T&) , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&
    ,const U&) , int size_max , T enum_T(const int&) , int enum_T_inv(const T&)>
// class EnumerationZetaTransform :
// public SemiRingForZetaTransform<T,U,a_U,z_U,m_U,size_max> ,
// public PartiallyOrderedSetForZetaTransform<T,E,E_inv,U,size_max>
// {
// public:
// inline EnumerationZetaTransform( const int& size );
// private:
// inline T e( const int& i );
// inline int e_inv( const T& t );
// };
// // template <typename T , typename U , int size_max> inline ZetaTransformBody<T,U,size_max>::ZetaTransformBody( const int& size ) : m_length() ,
    m_memory() , m_memory_inv() , m_size( size ) , m_val() {}
// template <typename T , typename U , int size_max> inline ZetaTransformBody<T,U,size_max>::ZetaTransformBody( const int& size ) : m_length() ,
    m_memory() , m_memory_inv() , m_size( size ) , m_val(size_max) {}
// template <typename T , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max> inline
    SemiRingForZetaTransform<T,U,a_U,z_U,m_U,size_max>::SemiRingForZetaTransform( const int& dummy ) :
// ZetaTransformBody<T,U,size_max>( dummy )
// {
// using base = ZetaTransformBody<T,U,size_max>;
// const U& zero = z_U();
// if( base::m_val[0] != zero ){
// for( int i = 0 ; i < base::m_size ; i++ ){
// base::m_val[i] = zero;
// }
// }
// }
// template <list<int> E(const int&) , list<int> E_inv(const int&) , int size_max> inline ZetaTransform<E,E_inv,size_max>::ZetaTransform( const int&
    size ) :
// ZetaTransformBody<int,ll,size_max>( size ) ,
// PartiallyOrderedSetForZetaTransform<int,E,E_inv,ll,size_max>()
// {}
// // template <list<int> E(const int&) , list<int> E_inv(const int&) , int size_max> inline ZetaTransform<E,E_inv,size_max>::ZetaTransform( const
    int& size , const ll ( &a )[size_max] ) :
// template <list<int> E(const int&) , list<int> E_inv(const int&) , int size_max> inline ZetaTransform<E,E_inv,size_max>::ZetaTransform( const int&
    size , const vector<ll>& a ) :
// ZetaTransformBody<int,ll,size_max>( size ) ,
// PartiallyOrderedSetForZetaTransform<int,E,E_inv,ll,size_max>() ,
// EnumerationForZetaTransform<ll,size_max>()
// {
// using base = ZetaTransformBody<int,ll,size_max>;
// for( int i = 0 ; i < base::m_size ; i++ ){
// ll& m_val_i = base::m_val[i] = a[i];
// list<int> sub_i = E( i );
// while( ! sub_i.empty() ){
// m_val_i += a[sub_i.front()];
// sub_i.pop_front();
// }
// }
// }
// template <typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max> inline FastZetaTransform<U,a_U,z_U
    ,m_U,size_max>::FastZetaTransform( const int& digit ) :
// ZetaTransformBody<int,U,size_max>( size ) ,
// SemiRingForZetaTransform<int,U,a_U,z_U,m_U,size_max>( size ) ,
// EnumerationForZetaTransform<U,size_max>() ,
// m_digit( digit )
// {}
// template <typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max> inline FastZetaTransform<U,a_U,z_U
    ,m_U,size_max>::FastZetaTransform( const int& digit , const U ( &a )[size_max] ) :
// ZetaTransformBody<int,U,size_max>( 1 << digit ) ,
// SemiRingForZetaTransform<int,U,a_U,z_U,m_U,size_max>( size )
// {
// using base = ZetaTransformBody<int,U,size_max>;
// for( int i = 0 ; i < base::m_size ; i++ ){
// base::m_val[i] = a[i];
// }
// int power = 1;
// for( int d = 0 ; d < m_digit ; d++ , power <<= 1 ){
// for( int i = 0 ; i < base::m_size ; i++ ){
// if( ( i & power ) != 0 ){
// U& m_val_i = base::m_val[i];
// m_val_i = a_U( m_val_i , base::m_val[i ^ power] );
// }
// }
// }
// }
// template <typename T , list<T> E(const T&) , list<T> E_inv(const T&) , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&
    ,const U&) , int size_max> inline MemorisationZetaTransform<T,E,E_inv,U,a_U,z_U,m_U,size_max>::MemorisationZetaTransform( const int& size ) :
// ZetaTransformBody<T,U,size_max>( size ) ,
// SemiRingForZetaTransform<T,U,a_U,z_U,m_U,size_max>( size ) ,
// PartiallyOrderedSetForZetaTransform<T,E,E_inv,U,size_max>()
// {}
// template <typename T , list<T> E(const T&) , list<T> E_inv(const T&) , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&
    ,const U&) , int size_max , T enum_T(const int&) , int enum_T_inv(const T&)> inline EnumerationZetaTransform<T,E,E_inv,U,a_U,z_U,m_U,size_max
    ,enum_T,enum_T_inv>::EnumerationZetaTransform( const int& size ) :
// ZetaTransformBody<T,U,size_max>( size ) ,
// SemiRingForZetaTransform<T,U,a_U,z_U,m_U,size_max>( size ) ,
// PartiallyOrderedSetForZetaTransform<T,E,E_inv,U,size_max>()
// {}
// template <typename T , typename U , int size_max> inline void ZetaTransformBody<T,U,size_max>::Add( const T& t , const U& u )
// {
// list<T> sup = Sup( t );
// sup.push_front( t );
// while( ! sup.empty() ){
// U& m_val_i = m_val[e_inv( sup.front() )];
// m_val_i = Sum( m_val_i , u );
// sup.pop_front();
// }
// return;
// }
// template <typename T , typename U , int size_max> inline void ZetaTransformBody<T,U,size_max>::AddAll( const U& u )
// {
// for( int i = 0 ; i < m_size ; i++ ){
// U& m_val_i = m_val[i];
// m_val_i = Sum( m_val_i , Prod( Sub( e( i ) ).size() , u ) );
// }
// return;
// }
// template <typename T , typename U , int size_max> inline ZetaTransformBody<T,U,size_max>& ZetaTransformBody<T,U,size_max>::operator+=( const
    ZetaTransformBody<T,U,size_max>& a )
// {
// for( int i = 0 ; i < m_size ; i++ ){
// U& m_val_i = m_val[i];
// m_val_i = Sum( m_val_i , a.m_val[i] );
// }
// return *this;
// }
// template <typename T , typename U , int size_max> inline void ZetaTransformBody<T,U,size_max>::MultiplyAll( const U& u )
// {
// for( int i = 0 ; i < m_size ; i++ ){
// U& m_val_i = m_val[i];
// m_val_i = Prod( m_val_i , u );
// }
// return;
// }
// template <typename T , typename U , int size_max> inline ZetaTransformBody<T,U,size_max>& ZetaTransformBody<T,U,size_max>::operator*=( const
    ZetaTransformBody<T,U,size_max>& a )
// {
// for( int i = 0 ; i < m_size ; i++ ){
// U& m_val_i = m_val[i];
// m_val_i = Prod( m_val_i , a.m_val[i] );
// }
// return *this;
// }
// template <typename T , typename U , int size_max> inline U ZetaTransformBody<T,U,size_max>::Get( const T& t ) {
    DEFINITION_OF_GET_FOR_ZETA_TRANSFORM( Moevius ); }
// template <typename T , typename U , int size_max> template <int mu(const T&,const T&)> inline U ZetaTransformBody<T,U,size_max>::Get( const T& t
    ) { DEFINITION_OF_GET_FOR_ZETA_TRANSFORM( mu ); }
// template <typename T , typename U , int size_max> inline const U& ZetaTransformBody<T,U,size_max>::InitialSegmentSum( const T& t ) { return
    m_val[e_inv( t )]; }
// template <typename T , typename U , int size_max> template <typename S , T f_inv_max(const S&) , list<S> r(const S&)> inline U ZetaTransformBody
    <T,U,size_max>::InverseImageSum( const S& s ) { DEFINITION_OF_INVERSE_IMAGE_SUM_FOR_ZETA_TRANSFORM( Moevius ); }
// template <typename T , typename U , int size_max> template <typename S , T f_inv_max(const S&) , list<S> r(const S&) , int mu(const T&,const T&)>
    inline U ZetaTransformBody<T,U,size_max>::InverseImageSum( const S& s ) { DEFINITION_OF_INVERSE_IMAGE_SUM_FOR_ZETA_TRANSFORM( mu ); }
// template <typename T , typename U , int size_max> template <typename S , T f_inv_max(const S&)> inline const U& ZetaTransformBody<T,U,size_max
    >::InitialSegmentInverseImageSum( const S& s ) { return m_val[e_inv( f_inv_max( s ) )]; }
// template <typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max> inline void FastZetaTransform<U,a_U
    ,z_U,m_U,size_max>::FastMoeviusTransform( U ( &a )[size_max] )
// {
// using base = ZetaTransformBody<int,U,size_max>;
// for( int i = 0 ; i < base::m_size ; i++ ){
// a[i] = base::m_val[i];
// }
// int power = 1;
// for( int d = 0 ; d < m_digit ; d++ , power <<= 1 ){
// for( int i = 0 ; i < base::m_size ; i++ ){
// if( ( i & power ) != 0 ){
// U& a_i = a[i];
// a_i = a_U( a_i , m_U( -1 , a[i ^ power] ) );
// }
// }
// }
// }
// template <typename T , typename U , int size_max>
// T ZetaTransformBody<T,U,size_max>::e( const int& i )
// {
// assert( i < m_length );
// return m_memory_inv[i];
// }
// template <typename U , int size_max> inline int EnumerationForZetaTransform<U,size_max>::e( const int& i ) { return i; }
// template <typename T , list<T> E(const T&) , list<T> E_inv(const T&) , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&
    ,const U&) , int size_max , T enum_T(const int&) , int enum_T_inv(const T&)> inline T EnumerationZetaTransform<T,E,E_inv,U,a_U,z_U,m_U,size_max
    ,enum_T,enum_T_inv>::e( const int& i ) { return enum_T( i ); }
// template <typename T , typename U , int size_max>
// int ZetaTransformBody<T,U,size_max>::e_inv( const T& t )
// {
// if( m_memory.count( t ) == 0 ){
// assert( m_length < m_size );
// m_memory_inv.push_back( t );
// return m_memory[t] = m_length++;
// }
// return m_memory[t];
// }
// template <typename U , int size_max> inline int EnumerationForZetaTransform<U,size_max>::e_inv( const int& t ) { return t; }
// template <typename T , list<T> E(const T&) , list<T> E_inv(const T&) , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&
    ,const U&) , int size_max , T enum_T(const int&) , int enum_T_inv(const T&)> inline int EnumerationZetaTransform<T,E,E_inv,U,a_U,z_U,m_U
    ,size_max,enum_T,enum_T_inv>::e_inv( const T& t ) { return enum_T_inv( t ); }
// template <typename T , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max> inline const U&
    SemiRingForZetaTransform<T,U,a_U,z_U,m_U,size_max>::Zero() const { return z_U(); }
// template <list<int> E(const int&) , list<int> E_inv(const int&) , int size_max> inline const ll& ZetaTransform<E,E_inv,size_max>::Zero() const {
    static const ll zero = 0; return zero; }
// template <typename T , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max> inline U
    SemiRingForZetaTransform<T,U,a_U,z_U,m_U,size_max>::Sum( const U& u0 , const U& u1 ) const { return a_U( u0 , u1 ); }
// template <list<int> E(const int&) , list<int> E_inv(const int&) , int size_max> inline ll ZetaTransform<E,E_inv,size_max>::Sum( const ll& u0 ,
    const ll& u1 ) const { return u0 + u1; }
// template <typename T , typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max> inline U
    SemiRingForZetaTransform<T,U,a_U,z_U,m_U,size_max>::Prod( const U& u0 , const U& u1 ) const { return m_U( u0 , u1 ); }
// template <list<int> E(const int&) , list<int> E_inv(const int&) , int size_max> inline ll ZetaTransform<E,E_inv,size_max>::Prod( const ll& u0 ,
    const ll& u1 ) const { return u0 * u1; }
// template <typename T , list<T> E(const T&) , list<T> E_inv(const T&) , typename U , int size_max> inline list<T>
    PartiallyOrderedSetForZetaTransform<T,E,E_inv,U,size_max>::Sub( const T& t ) const { return E( t ); }
// template <typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max> inline list<int> FastZetaTransform<U
    ,a_U,z_U,m_U,size_max>::Sub( const int& t ) const
// {
// list<int> sub{};
// sub.push_back( t );
// int sub_size = 1;
// int power = 1;
// for( int d = 0 ; d < m_digit ; d++ , power <<= 1 ){
// if( ( t & power ) != 0 ){
// auto itr = sub.begin();
// for( int i = 0 ; i < sub_size ; i++ , itr++ ){
// sub.push_back( *itr ^ power );
// }
// sub_size <<= 1;
// }
// }
// return sub;
// }
// template <typename T , list<T> E(const T&) , list<T> E_inv(const T&) , typename U , int size_max> inline list<T>
    PartiallyOrderedSetForZetaTransform<T,E,E_inv,U,size_max>::Sup( const T& t ) const { return E_inv( t ); }
// template <typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max> inline list<int> FastZetaTransform<U
    ,a_U,z_U,m_U,size_max>::Sup( const int& t ) const
// {
// list<int> sup{};
// sup.push_back( t );
// int sup_size = 1;
// int power = 1;
// for( int d = 0 ; d < m_digit ; d++ , power <<= 1 ){
// if( ( t & power ) == 0 ){
// auto itr = sup.begin();
// for( int i = 0 ; i < sup_size ; i++ , itr++ ){
// sup.push_back( *itr | power );
// }
// sup_size <<= 1;
// }
// }
// return sup;
// }
// template <typename T , list<T> E(const T&) , list<T> E_inv(const T&) , typename U , int size_max> inline int PartiallyOrderedSetForZetaTransform
    <T,E,E_inv,U,size_max>::Moevius( const T& t0 , const T& t1 )
// {
// using base = ZetaTransformBody<T,U,size_max>;
// const int i = base::e_inv( t0 );
// const int j = base::e_inv( t1 );
// map<int,int>& moevius_t0 = m_moevius[i];
// bool found = moevius_t0.count( j ) == 1;
// int& answer = moevius_t0[j];
// if( ! found ){
// if( i == j ){
// answer = 1;
// } else {
// list<T> sub = E( t1 );
// while( ! sub.empty() ){
// cerr << "" << endl;
// cerr << "" << endl;
// answer -= Moevius( t0 , sub.front() );
// sub.pop_front();
// }
// }
// }
// return answer;
// }
// template <typename U , U a_U(const U&,const U&) , const U& z_U() , U m_U(const U&,const U&) , int size_max> int FastZetaTransform<U,a_U,z_U,m_U
    ,size_max>::Moevius( const int& t0 , const int& t1 )
// {
// int t = t1 ^ t0;
// int count = 0;
// while( t != 0 ){
// t -= t & -t;
// count++;
// }
// return ( count & 1 ) == 0 ? 1 : -1;
// }
template <typename INT , INT val_limit , int length_max> int TwoAryMoeviusFunction( const PrimeEnumeration<INT,val_limit,length_max>& prime , const
    int& t0 , const int& t1 )
{
// constexpr int size_max = val_limit * val_limit;
constexpr int size_max = val_limit;
static int memory[size_max];
static bool uninitialised = true;
if( uninitialised ){
vector<int> rest( size_max );
for( int n = 0 ; n < size_max ; n++ ){
memory[n] = 1;
rest[n] = n;
}
for( int i = 0 ; i < prime.m_LE ; i++ ){
const INT& p_i = prime.m_val[i];
int n = 0;
while( ( n += p_i ) < size_max ){
int& rest_n = rest[n] /= p_i;
memory[n] *= ( rest_n % p_i == 0 ? 0 : -1 );
}
}
for( int n = val_limit ; n < size_max ; n++ ){
if( rest[n] != 1 ){
memory[n] *= -1;
}
}
uninitialised = false;
}
assert( t1 % t0 == 0 );
return memory[ t1 / t0 ];
}
inline CEXPR( int , bound_N , 300000 ); // 05
list<int> divisor[bound_N+1] = {};
inline list<int> E(const int& i ) { return divisor[i]; }
inline list<int> E_inv(const int&) { return list<int>(); } // 使
// inline constexpr PrimeEnumeration<int,600,600> prime{};
inline PrimeEnumeration<int,300000,300000> prime{};
inline int mu( const int& n , const int& m ) { return TwoAryMoeviusFunction( prime , n , m ); }
ll f( const int& N , const ll& N2 , const ll& m )
{
// ll A[bound_N + 1];
// vector<ll> A( bound_N + 1 );
// FOREQ( i , 1 , N ){
// A[i] = m * i / N2;
// }
// ZetaTransform<E,E_inv,bound_N + 1> zt{ N + 1 , A };
START_WATCH( "construct zt" );
vector<ll> zt( N + 1 );
FOREQ( i , 1 , N ){
zt[i] = m * i / N2;
}
FOR( i , 0 , prime.m_LE ){
const int& p_i = prime.m_val[i];
if( N < p_i ){
break;
}
FOREQINV( n , N / p_i , 0 ){
zt[n * p_i] -= zt[n];
}
}
STOP_WATCH();
START_WATCH( "compute answer" );
ll answer = 0;
FOREQ( i , 1 , N ){
// answer += f.Get<mu>( i );
answer += zt[i];
}
STOP_WATCH();
return answer;
}
int main()
{
UNTIE;
LIBRARY_SEARCH;
CEXPR( int , bound_T , 15000 );
CIN_ASSERT( T , 1 , bound_T );
static ll euler_sum[bound_N + 1];
MemoriseEulerFunction( prime , euler_sum );
FOREQ( i , 2 , bound_N ){
euler_sum[i] += euler_sum[i-1];
}
MemoriseEnumerateDivisor( divisor );
FOREQ( i , 1 , bound_N ){
divisor[i].pop_back();
}
REPEAT( T ){
CIN_ASSERT( N , 1 , bound_N );
ll N2 = ll( N ) * N;
CIN_ASSERT( K , 1 , N2 );
ll& M = euler_sum[N];
if( K == M ){
COUT( "1/1" );
continue;
}
if( K >= M * 2 ){
COUT( -1 );
continue;
}
bool over = K > M;
if( over ){
K = M * 2 - K;
}
BS1( m , 0 , N2 - 1 , f( N , N2 , m ) , K );
FOREQ( q , 1 , N ){
int p = q * m / N2;
if( p > q * ( m - 1 ) / N2 ){
if( over ){
swap( p , q );
}
COUT( p << "/" << q );
break;
}
}
}
// CEXPR( int , bound_N , 1000000000 ); // 09
// CEXPR( ll , bound_N , 1000000000000000000 ); // 018
// CEXPR( int , bound_M , 100000 ); // 05
// // CEXPR( int , bound_M , 1000000000 ); // 09
// // CEXPR( ll , bound_M , 1000000000000000000 ); // 018
// CIN_ASSERT( M , 0 , bound_M );
// CEXPR( ll , P , 998244353 );
// CEXPR( ll , P , 1000000007 );
// CEXPR( int , bound_Q , 100000 );
// CIN_ASSERT( Q , 1 , bound_Q );
// REPEAT( Q ){
// COUT( N );
// }
// RETURN( N );
QUIT;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0