結果
| 問題 |
No.2785 四乗足す四の末尾の0
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2023-02-24 01:45:07 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,516 bytes |
| コンパイル時間 | 3,433 ms |
| コンパイル使用メモリ | 96,168 KB |
| 最終ジャッジ日時 | 2025-02-10 20:10:23 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 9 |
ソースコード
// 誤解法(オーバーフロー)チェック
#pragma GCC optimize ( "O3" )
#pragma GCC optimize( "unroll-loops" )
#pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" )
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <cassert>
using namespace std;
using ll = long long;
#define MAIN main
#define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type
#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr )
#define CEXPR( LL , BOUND , VALUE ) constexpr const 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 REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT ## HOW_MANY_TIMES , 0 , HOW_MANY_TIMES )
#define QUIT return 0
#define COUT( ANSWER ) cout << ( ANSWER ) << "\n"
#define RETURN( ANSWER ) COUT( ANSWER ); QUIT
template <typename INT , INT val_limit , int length_max>
class PrimeEnumeration
{
public:
INT m_val[length_max];
int m_length;
inline constexpr PrimeEnumeration();
};
template <typename INT , INT val_limit , int length_max>
inline constexpr PrimeEnumeration<INT,val_limit,length_max>::PrimeEnumeration() : m_val() , m_length( 0 )
{
bool is_comp[val_limit] = {};
for( INT i = 2 ; i < val_limit ; i++ ){
if( is_comp[i] == false ){
INT j = i;
while( ( j += i ) < val_limit ){
is_comp[j] = true;
}
m_val[m_length++] = i;
}
}
}
int MAIN()
{
UNTIE;
CEXPR( int , bound_T , 100000 );
CIN_ASSERT( T , 1 , bound_T );
CEXPR( ll , bound_N , 1000000000 );
constexpr PrimeEnumeration<int,31622,3401> pe{}; // 31622以下の素数は3401個
string Yes = "Yes";
string No = "No";
REPEAT( T ){
CIN_ASSERT( N , - bound_N , bound_N );
if( N == 1 || N == -1 ){
COUT( Yes );
COUT( 0 );
} else {
ll N2 = max( N *= N , ll( 2 ) );
( N *= N ) += 4;
int count = 0;
while( N % 10 == 0 ){
N /= 10;
count++;
}
if( count > 0 ){
COUT( No );
COUT( count );
} else {
bool is_prime = true;
FOR( i , 0 , pe.m_length ){
const int& pe_i = pe.m_val[i];
if( pe_i > N2 ){
break;
} else if( N % pe_i == 0 ){
is_prime = false;
break;
}
}
COUT( is_prime ? Yes : No );
COUT( 0 );
}
}
}
QUIT;
}