結果
問題 | No.2976 高階多点評価 |
ユーザー |
👑 |
提出日時 | 2023-11-06 18:50:24 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 179 ms / 1,000 ms |
コード長 | 6,065 bytes |
コンパイル時間 | 3,687 ms |
コンパイル使用メモリ | 218,444 KB |
最終ジャッジ日時 | 2025-02-17 19:48:57 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 |
ソースコード
#ifdef DEBUG#define _GLIBCXX_DEBUG#define SIGNAL signal( SIGABRT , &AlertAbort );#define DEXPR( LL , BOUND , VALUE , DEBUG_VALUE ) CEXPR( LL , BOUND , DEBUG_VALUE )#define ASSERT( A , MIN , MAX ) CERR( "ASSERTチェック: " , ( MIN ) , ( ( MIN ) <= A ? "<=" : ">" ) , A , ( A <= ( MAX ) ? "<=" : ">" ) , ( MAX )); assert( ( MIN ) <= A && A <= ( MAX ) )#define CERR( ... ) VariadicCout( cerr , __VA_ARGS__ ) << endl#define COUT( ... ) VariadicCout( cout << "出力: " , __VA_ARGS__ ) << endl#define CERR_A( A , N ) OUTPUT_ARRAY( cerr , A , N ) << endl#define COUT_A( A , N ) cout << "出力: "; OUTPUT_ARRAY( cout , A , N ) << endl#define CERR_ITR( A ) OUTPUT_ITR( cerr , A ) << endl#define COUT_ITR( A ) cout << "出力: "; OUTPUT_ITR( cout , A ) << endl#else#pragma GCC optimize ( "O3" )#pragma GCC optimize ( "unroll-loops" )#pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" )#define SIGNAL#define DEXPR( LL , BOUND , VALUE , DEBUG_VALUE ) CEXPR( LL , BOUND , VALUE )#define ASSERT( A , MIN , MAX ) assert( ( MIN ) <= A && A <= ( MAX ) )#define CERR( ... )#define COUT( ... ) VariadicCout( cout , __VA_ARGS__ ) << "\n"#define CERR_A( A , N )#define COUT_A( A , N ) OUTPUT_ARRAY( cout , A , N ) << "\n"#define CERR_ITR( A )#define COUT_ITR( A ) OUTPUT_ITR( cout , A ) << "\n"#endif#include <bits/stdc++.h>using namespace std;using uint = unsigned int;using ll = long long;using ull = unsigned long long;#define REPEAT_MAIN( BOUND ) int main(){ ios_base::sync_with_stdio( false ); cin.tie( nullptr ); SIGNAL; SET_PRECISION( 5 ); DEXPR( int ,bound_test_case_num , BOUND , min( BOUND , 100 ) ); int test_case_num = 1; if constexpr( bound_test_case_num > 1 ){ SET_ASSERT( test_case_num , 1, bound_test_case_num ); } REPEAT( test_case_num ){ if constexpr( bound_test_case_num > 1 ){ CERR( "testcase " ,VARIABLE_FOR_REPEAT_test_case_num , ":" ); } Solve(); CERR( "" ); } }#define TYPE_OF( VAR ) decay_t<decltype( VAR )>#define CEXPR( LL , BOUND , VALUE ) constexpr LL BOUND = VALUE#define CIN( LL , ... ) LL __VA_ARGS__; VariadicCin( cin , __VA_ARGS__ )#define SET_ASSERT( A , MIN , MAX ) cin >> A; ASSERT( A , MIN , MAX )#define CIN_ASSERT( A , MIN , MAX ) TYPE_OF( MAX ) A; SET_ASSERT( A , MIN , MAX )#define SET_A( A , N ) SOLVE_ONLY; FOR( VARIABLE_FOR_CIN_A , 0 , N ){ cin >> A[VARIABLE_FOR_CIN_A]; }#define CIN_A( LL , A , N ) vector<LL> A( N ); SET_A( A , N );#define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( TYPE_OF( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ )#define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT_ ## HOW_MANY_TIMES , 0 , HOW_MANY_TIMES )#define SET_PRECISION( DECIMAL_DIGITS ) cout << fixed << setprecision( DECIMAL_DIGITS )#define OUTPUT_ARRAY( OS , A , N ) FOR( VARIABLE_FOR_OUTPUT_ARRAY , 0 , N ){ OS << A[VARIABLE_FOR_OUTPUT_ARRAY] << (VARIABLE_FOR_OUTPUT_ARRAY==N-1?"":" "); } OS#define OUTPUT_ITR( OS , A ) { auto ITERATOR_FOR_OUTPUT_ITR = A.begin() , END_FOR_OUTPUT_ITR = A.end(); bool VARIABLE_FOR_OUTPUT_ITR =ITERATOR_FOR_COUT_ITR != END_FOR_COUT_ITR; while( VARIABLE_FOR_OUTPUT_ITR ){ OS << *ITERATOR_FOR_COUT_ITR; ( VARIABLE_FOR_OUTPUT_ITR =++ITERATOR_FOR_COUT_ITR != END_FOR_COUT_ITR ) ? OS : OS << " "; } } OS#define RETURN( ... ) COUT( __VA_ARGS__ ); return// 入出力用template <class Traits> inline basic_istream<char,Traits>& VariadicCin( basic_istream<char,Traits>& is ) { return is; }template <class Traits , typename Arg , typename... ARGS> inline basic_istream<char,Traits>& VariadicCin( basic_istream<char,Traits>& is , Arg& arg ,ARGS&... args ) { return VariadicCin( is >> arg , args... ); }template <class Traits> inline basic_istream<char,Traits>& VariadicGetline( basic_istream<char,Traits>& is , const char& separator ) { return is; }template <class Traits , typename Arg , typename... ARGS> inline basic_istream<char,Traits>& VariadicGetline( basic_istream<char,Traits>& is , constchar& separator , Arg& arg , ARGS&... args ) { return VariadicGetline( getline( is , arg , separator ) , separator , args... ); }template <class Traits , typename Arg> inline basic_ostream<char,Traits>& VariadicCout( basic_ostream<char,Traits>& os , const Arg& arg ) { return os<< arg; }template <class Traits , typename Arg1 , typename Arg2 , typename... ARGS> inline basic_ostream<char,Traits>& VariadicCout( basic_ostream<char,Traits>& os , const Arg1& arg1 , const Arg2& arg2 , const ARGS&... args ) { return VariadicCout( os << arg1 << " " , arg2 , args... ); }// デバッグ用#ifdef DEBUGinline void AlertAbort( int n ) { CERR("abort関数が呼ばれました。assertマクロのメッセージが出力されていない場合はオーバーフローの有無を確認をしてください。" ); }void AutoCheck( bool& auto_checked );#endifdouble non_std_cos( const double& x ){double answer = 0;double temp = 1;double xx = x * x;FOR( i , 0 , 10 ){answer += temp;temp *= - xx / ( ( 2 * i + 1 ) * ( 2 * i + 2 ) );}return answer;}CEXPR( double , pi , 3.1415926535879 );CEXPR( double , pi2 , pi * 2 );double non_std_sin( const double& x ){double answer = 0;double temp = x > pi ? x - int( ( x - pi ) / pi2 + 1 ) * pi2 : x < -pi ? x + int( ( x + pi ) / pi2 + 1 ) * pi2 : x;double xx = temp * temp;FOR( i , 0 , 10 ){answer += temp;temp *= - xx / ( ( 2 * i + 2 ) * ( 2 * i + 3 ) );}return answer;}double non_std_acos( const double& U ){CEXPR( double , bound_dif , 0.00000000383 );double l = 0;double r = pi;double m = ( l + r ) / 2;double y = non_std_cos( m );while( abs( y - U ) >= bound_dif ){( y < U ? r : l ) = m;m = ( l + r ) / 2;y = non_std_cos( m );}return m;}inline void Solve(){CEXPR( int , bound_N , 200 ); // 0が2個CIN_ASSERT( N , 0 , bound_N );CIN( double , X );double U = - X / sqrt( X * X + 1 );double theta = non_std_acos( U );RETURN( non_std_sin( ( N + 1 ) * theta ) / non_std_sin( theta ) );}REPEAT_MAIN(100000);