// 誤解法(m!の代わりに2^4*3^2*5*7*11*13*17 = 12252240を用いた近似解)チェック #pragma GCC optimize ( "O3" ) #pragma GCC optimize( "unroll-loops" ) #pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" ) #include using namespace std; using ll = long long; #define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) #define TYPE_OF( VAR ) decay_t #define CEXPR( LL , BOUND , VALUE ) constexpr LL BOUND = VALUE #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 QUIT return 0 #define COUT( ANSWER ) cout << ANSWER << "\n" #define SET_PRECISION( DECIMAL_DIGITS ) cout << fixed << setprecision( DECIMAL_DIGITS ) #define RETURN( ANSWER ) COU( ( ANSWER ) ); QUIT int main() { CEXPR( ll , bound , 20 ); CIN_ASSERT( N , - bound , bound ); bool negative; if( N < 0 ){ negative = true; N *= -1; } else { negative = false; } CEXPR( ll , m_factorial , 12252240 ); CEXPR( double , pi , 3.14159265358979323846264338 ); double theta = 2 * pi / m_factorial; complex answer{ 0.0 , 0.0 }; complex zeta{ cos( theta ) , sin( theta ) }; complex zeta_N{ 1.0 , 0.0 }; complex zeta_power = negative ? 1.0 / zeta : zeta; while( N > 0 ){ ( N & 1 ) == 1 ? zeta_N *= zeta_power : zeta_N; zeta_power *= zeta_power; N >>= 1; } complex zeta_N_power{ 1.0 , 0.0 }; zeta_power = zeta_N_power; FOR( k , 0 , m_factorial ){ answer += zeta_N_power / ( zeta_power * ( zeta_power + 1.0 ) + 10.0 ); zeta_N_power *= zeta_N; zeta_power += zeta; } answer /= m_factorial; CEXPR( ll , d , 1000000000000000000 ); ll n = answer.real() * d; COUT( n << "/" << d ); QUIT; }