結果

問題 No.2190 平方数の下12桁
ユーザー 👑 p-adic
提出日時 2022-09-02 17:58:07
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,181 bytes
コンパイル時間 568 ms
コンパイル使用メモリ 67,040 KB
最終ジャッジ日時 2025-02-07 00:36:35
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <stdio.h>
#include <stdint.h>
using namespace std;

using ll = long long;

#define CIN( LL , A ) LL A; cin >> A 
#define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( ll VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) 
#define RETURN( ANSWER ) cout << ( ANSWER ) << endl; return 0 

#include <cassert>

int main()
{
  // CIN( string , S );
  // assert( S.size() == 12 );
  // FOR( i , 0 , 12 ){
  //   string c = S.substr( i , 1 );
  //   bool b = false;
  //   FOR( n , 0 , 10 ){
  //     if( c == to_string( n ) ){
  // 	b = true;
  // 	n = 10;
  //     }
  //   }
  //   assert( b );
  // }
  CIN( ll , S );
  assert( S < 1000000000000 );
  ll p[2] = { 2 , 5 };
  ll exponent[2] = {};
  FOR( i , 0 , 2 ){
    ll& p_i = p[i];
    ll& exponent_i = exponent[i];
    while( S % p_i == 0 && exponent_i < 12 ){
      S /= p_i;
      exponent_i++;
    }
    if( exponent_i % 2 != 0 ){
      RETURN( "NO" );
    }
  }
  if( exponent[0] < 12 ){
    ll r2 = S % 8;
    if( r2 != 1 ){
      RETURN( "NO" );
    }
  }
  if( exponent[1] < 12 ){
    ll r5 = S % 5;
    if( r5 != 1 && r5 != 4 ){
      RETURN( "NO" );
    }
  }
  RETURN( "YES" );
}
0