結果

問題 No.2785 四乗足す四の末尾の0
ユーザー MZKiMZKi
提出日時 2023-03-14 23:43:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 307 ms / 2,000 ms
コード長 1,074 bytes
コンパイル時間 4,242 ms
コンパイル使用メモリ 260,744 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 12:08:08
合計ジャッジ時間 6,452 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 31 ms
4,348 KB
testcase_15 AC 297 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 307 ms
4,348 KB
testcase_18 AC 303 ms
4,348 KB
testcase_19 AC 304 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<atcoder/all>
using namespace atcoder;

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

void solve(){
    ll n;
    cin >> n;

    int ans2 = 0;
    int ans5 = 0;
    ll a2 = n*n+2*n+2;
    ll b2 = n*n-2*n+2;
    ll a5 = n*n+2*n+2;
    ll b5 = n*n-2*n+2;
    while(a2 % 2 == 0){ans2++; a2 /= 2;}
    while(b2 % 2 == 0){ans2++; b2 /= 2;}
    while(a5 % 5 == 0){ans5++; a5 /= 5;}
    while(b5 % 5 == 0){ans5++; b5 /= 5;}
    cout << (abs(n) == 1 ? "Yes" : "No") << endl;
    cout << min(ans2, ans5) << endl;
}
int main() {
    int t;
    cin >> t;
    while(t--)solve();
}
0