mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 13:56:26 +00:00
parent
237c953596
commit
b11f436570
57
S2OJ/1508/1508.cpp
Normal file
57
S2OJ/1508/1508.cpp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 1e6 + 5;
|
||||||
|
|
||||||
|
long long k, _k, cnt, p[N], c[N], ans = 1;
|
||||||
|
bool flag;
|
||||||
|
|
||||||
|
long long binpow(long long a, long long b) {
|
||||||
|
long long res = 1;
|
||||||
|
|
||||||
|
while (b) {
|
||||||
|
if (b & 1) res *= a;
|
||||||
|
a *= a;
|
||||||
|
b >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
cin >> k;
|
||||||
|
|
||||||
|
_k = k;
|
||||||
|
|
||||||
|
for (long long i = 2; i * i <= k; i++) {
|
||||||
|
if (k % i == 0) {
|
||||||
|
p[++cnt] = i;
|
||||||
|
|
||||||
|
while (k % i == 0) {
|
||||||
|
k /= i;
|
||||||
|
c[cnt]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k) {
|
||||||
|
p[++cnt] = k;
|
||||||
|
c[cnt] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= cnt; i++) {
|
||||||
|
ans *= binpow(p[i], static_cast<long long>(std::ceil(static_cast<long double>(c[i]) / 2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << (ans % _k ? ans : -1) << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
S2OJ/1508/data/data1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/data9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/data9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1508/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1508/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user