結果
| 問題 |
No.2785 四乗足す四の末尾の0
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2024-07-03 00:24:34 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 308 ms / 2,000 ms |
| コード長 | 827 bytes |
| コンパイル時間 | 2,505 ms |
| コンパイル使用メモリ | 244,208 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 00:24:40 |
| 合計ジャッジ時間 | 5,067 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#define _GLIBCXX_DEBUG
#else
#define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
int t;
cin >> t;
while (t--) {
ll n;
cin >> n;
if (abs(n) == 1) {
cout << "Yes\n0" << endl;
}
else {
cout << "No" << endl;
ll a = n * n + 2 * n + 2;
ll b = n * n - 2 * n + 2;
ll cnt2 = 0, cnt5 = 0;
while (a % 2 == 0) {
a /= 2, cnt2++;
}
while (a % 5 == 0) {
a /= 5, cnt5++;
}
while (b % 2 == 0) {
b /= 2, cnt2++;
}
while (b % 5 == 0) {
b /= 5, cnt5++;
}
cout << min(cnt2, cnt5) << endl;
}
}
return 0;
}
a01sa01to