結果

問題 No.2785 四乗足す四の末尾の0
ユーザー GOTKAKO
提出日時 2024-06-14 22:16:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 194,356 KB
最終ジャッジ日時 2025-02-21 22:07:39
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int T; cin >> T;
    while(T--){
        long long N; cin >> N;
        N = abs(N);
        if(N == 1){cout << "Yes\n0\n"; continue;}
        cout << "No\n";
        int answer = 0;
        long long x = N*N-2*N+2;
        bool two = false,five = false;
        while(x%10 == 0) x /= 10,answer++;
        if(x%2 == 0) two = true;
        if(x%5 == 0) five = true;
        
        x = N*N+2*N+2;
        while(x%10 == 0) x /= 10,answer++;
        if(x%2 == 0) two = true;
        if(x%5 == 0) five = true;
        
        if(two && five) answer++;
        cout << answer << "\n";
    }

}
0