結果
| 問題 |
No.2785 四乗足す四の末尾の0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-14 22:12:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 273 ms / 2,000 ms |
| コード長 | 728 bytes |
| コンパイル時間 | 1,734 ms |
| コンパイル使用メモリ | 167,440 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-14 22:12:42 |
| 合計ジャッジ時間 | 3,774 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
int main(void){
cin.tie(nullptr); ios_base::sync_with_stdio(false);
int T;
cin >> T;
while(T--){
ll N;
cin >> N;
if(labs(N)==1){
cout << "Yes" << endl;
cout << 0 << endl;
continue;
}
if(N==0){
cout << "No" << endl;
cout << 0 << endl;
continue;
}
ll x=N*N+2*N+2,y=N*N-2*N+2;
ll c=0,d=0;
while(x%2==0){
c++;
x/=2;
}
while(x%5==0){
d++;
x/=5;
}
ll cc=0,dd=0;;
while(y%2==0){
cc++;
y/=2;
}
while(y%5==0){
dd++;
y/=5;
}
cout << "No" << endl;
cout << min(c+cc,d+dd) << endl;
}
return 0;
}