diff --git a/S2OJ/1508/1508.cpp b/S2OJ/1508/1508.cpp new file mode 100644 index 00000000..dbb3612c --- /dev/null +++ b/S2OJ/1508/1508.cpp @@ -0,0 +1,57 @@ +#include +#include +#include + +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(std::ceil(static_cast(c[i]) / 2))); + } + + cout << (ans % _k ? ans : -1) << endl; + + return 0; +} diff --git a/S2OJ/1508/data/data1.in b/S2OJ/1508/data/data1.in new file mode 100644 index 00000000..dff08b35 --- /dev/null +++ b/S2OJ/1508/data/data1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76bf5d2e3a266279e409df494510f49249980ce2254994539e6defe77528bc10 +size 7 diff --git a/S2OJ/1508/data/data1.out b/S2OJ/1508/data/data1.out new file mode 100644 index 00000000..30fc34cb --- /dev/null +++ b/S2OJ/1508/data/data1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98804609813a673d6ce3b5330f2bee12ef01ef8ee88c5e02dcc3eccf666e0f92 +size 6 diff --git a/S2OJ/1508/data/data10.in b/S2OJ/1508/data/data10.in new file mode 100644 index 00000000..cf8d1743 --- /dev/null +++ b/S2OJ/1508/data/data10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43beb97eab03380c87c60987f080c0224a6a53699367b6ef2f91c1f18d2b2592 +size 12 diff --git a/S2OJ/1508/data/data10.out b/S2OJ/1508/data/data10.out new file mode 100644 index 00000000..311c4506 --- /dev/null +++ b/S2OJ/1508/data/data10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee3aa64bb94a50845d5024cd4bd20202a4567aed5cd5328c0d97e9920775fc28 +size 3 diff --git a/S2OJ/1508/data/data2.in b/S2OJ/1508/data/data2.in new file mode 100644 index 00000000..19f62fe2 --- /dev/null +++ b/S2OJ/1508/data/data2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b6449e30c89311794225204605afd32d40c8c63e063600c347d675791574809 +size 7 diff --git a/S2OJ/1508/data/data2.out b/S2OJ/1508/data/data2.out new file mode 100644 index 00000000..c600bbd0 --- /dev/null +++ b/S2OJ/1508/data/data2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:facf2feac57a3aa86b50c4692540870bf5f4fc0054d68653cc91d3de1e7ff5bd +size 6 diff --git a/S2OJ/1508/data/data3.in b/S2OJ/1508/data/data3.in new file mode 100644 index 00000000..a60be2ac --- /dev/null +++ b/S2OJ/1508/data/data3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e08fcfee8f6c8e93374eaa1dce0e094f846bb0d58c5b5aaf847bf1d4414a59b +size 7 diff --git a/S2OJ/1508/data/data3.out b/S2OJ/1508/data/data3.out new file mode 100644 index 00000000..0515ffa7 --- /dev/null +++ b/S2OJ/1508/data/data3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:321b7c50756d8b35b341ca967e0206f34800399defde87a0200d2f42045c63b6 +size 5 diff --git a/S2OJ/1508/data/data4.in b/S2OJ/1508/data/data4.in new file mode 100644 index 00000000..cc045753 --- /dev/null +++ b/S2OJ/1508/data/data4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6abe4318430bb2af08e2b7e22709aef6c7606627e8f01016d6f9a212f06eb5e2 +size 7 diff --git a/S2OJ/1508/data/data4.out b/S2OJ/1508/data/data4.out new file mode 100644 index 00000000..80211b58 --- /dev/null +++ b/S2OJ/1508/data/data4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc927f14786e701a06069cbc567ab043c8c5b9d21b13bf2b6c417ac64ea75fcb +size 6 diff --git a/S2OJ/1508/data/data5.in b/S2OJ/1508/data/data5.in new file mode 100644 index 00000000..e58e7be7 --- /dev/null +++ b/S2OJ/1508/data/data5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfec31b60734cf40a677c60c1dfc9076d50ad341777e674d2764d1e191594a6e +size 7 diff --git a/S2OJ/1508/data/data5.out b/S2OJ/1508/data/data5.out new file mode 100644 index 00000000..bd9c7a4c --- /dev/null +++ b/S2OJ/1508/data/data5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:caf6a69649c7b9face58a0ed33131f90ba6d789cad04ce548ef76532f27e55df +size 5 diff --git a/S2OJ/1508/data/data6.in b/S2OJ/1508/data/data6.in new file mode 100644 index 00000000..95e55e26 --- /dev/null +++ b/S2OJ/1508/data/data6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d6e184c8a9317b16642b65337f58a44cbcfecca4cd08fa81948b192ef9426426 +size 12 diff --git a/S2OJ/1508/data/data6.out b/S2OJ/1508/data/data6.out new file mode 100644 index 00000000..6548c036 --- /dev/null +++ b/S2OJ/1508/data/data6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:015a11011f828633bbf9b62da59f6943334cbf6bea2a9a68cfc42730cec151d4 +size 10 diff --git a/S2OJ/1508/data/data7.in b/S2OJ/1508/data/data7.in new file mode 100644 index 00000000..fa37cb51 --- /dev/null +++ b/S2OJ/1508/data/data7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6228a0810eba2e0c87a78267d4ea601109659bc7794400824ba1dfceb4094f59 +size 13 diff --git a/S2OJ/1508/data/data7.out b/S2OJ/1508/data/data7.out new file mode 100644 index 00000000..998e427c --- /dev/null +++ b/S2OJ/1508/data/data7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67a1b9ba520dd319c1e5ed0ae7d4b4f4605a7826bad72b92b8da597e9a411be7 +size 11 diff --git a/S2OJ/1508/data/data8.in b/S2OJ/1508/data/data8.in new file mode 100644 index 00000000..b690e80d --- /dev/null +++ b/S2OJ/1508/data/data8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2ac54ddb6786d24d0216817a92cf99be5fc12a0e23d970f2ebbf6824c7a8bf6 +size 13 diff --git a/S2OJ/1508/data/data8.out b/S2OJ/1508/data/data8.out new file mode 100644 index 00000000..182bada5 --- /dev/null +++ b/S2OJ/1508/data/data8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:200458402e72d9ae03a6a489bc186245f0107cc8b027201a8a7198241bd768c3 +size 12 diff --git a/S2OJ/1508/data/data9.in b/S2OJ/1508/data/data9.in new file mode 100644 index 00000000..5ab3c0b3 --- /dev/null +++ b/S2OJ/1508/data/data9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:486d0977e5f182deacc0b396c6860373a8c09e502e11aaa01e0bbe5055b93177 +size 13 diff --git a/S2OJ/1508/data/data9.out b/S2OJ/1508/data/data9.out new file mode 100644 index 00000000..c0ed26b2 --- /dev/null +++ b/S2OJ/1508/data/data9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef50770e9de909116778e7de69e98cfe758a5fce7d288b234c79c07eece0d22d +size 12 diff --git a/S2OJ/1508/data/problem.conf b/S2OJ/1508/data/problem.conf new file mode 100644 index 00000000..ebb8e46c --- /dev/null +++ b/S2OJ/1508/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:319d64f93cd04f108a6a89a8fb03b52bb51041327de44ee142065cb9552a0351 +size 177