結果
| 問題 |
No.300 平方数
|
| コンテスト | |
| ユーザー |
wonda_t_coffee
|
| 提出日時 | 2020-02-27 23:54:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 910 bytes |
| コンパイル時間 | 571 ms |
| コンパイル使用メモリ | 79,132 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-13 16:05:07 |
| 合計ジャッジ時間 | 2,544 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 39 WA * 4 |
ソースコード
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;
const int MOD = 1000000007; // 10^9 + 7
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll x; cin >> x;
ll ans = 1, d = 2, y = x;
for (ll d = 2; d * d <= x && y > 0; d++) {
int cnt = 0;
while (y % d == 0) {
y /= d;
cnt += 1;
}
if (cnt % 2 == 1) ans *= d;
ll dd = x / d;
if (dd == d) continue;
cnt = 0;
while (y % dd == 0) {
y /= dd;
cnt += 1;
}
if (cnt % 2 == 1) ans *= dd;
}
if (x == y) {
ans *= x;
}
cout << ans << endl;
}
wonda_t_coffee