diff --git a/problem/P1206/P1206.cpp b/problem/P1206/P1206.cpp new file mode 100644 index 00000000..12daf4c1 --- /dev/null +++ b/problem/P1206/P1206.cpp @@ -0,0 +1,66 @@ +#include + +using namespace std; + +class node { + private: + char c(int x) { + if (0 <= x && x <= 9) { + return x + '0'; + } + return x - 10 + 'A'; + } + int len; + int nums[20]; + + public: + node() { + len = 0; + } + node(int x, int b) { + len = 0; + while (x) { + nums[len] = x % b; + x /= b; + len++; + } + } + + int& operator[](int x) { + return nums[x]; + } + + const char* c_str() { + string s; + for (int i = len - 1; i >= 0; i--) { + s.push_back(c(nums[i])); + } + return s.c_str(); + } + string print() { + for (int i = len - 1; i >= 0; i--) { + cout << c(nums[i]); + } + return ""; + } + bool check() { + for (int i = 0; i < len; i++) { + if (nums[i] != nums[len - i - 1]) { + return false; + } + } + return true; + } +}; + +int main() { + int b; + cin >> b; + for (int i = 1; i <= 300; i++) { + node t = node(i * i, b); + if (t.check()) { + cout << node(i, b).print() << ' ' << t.print() << endl; + } + } + return 0; +} diff --git a/problem/P1206/data/P1206_1.in b/problem/P1206/data/P1206_1.in new file mode 100644 index 00000000..adccc0fc --- /dev/null +++ b/problem/P1206/data/P1206_1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5 +size 2 diff --git a/problem/P1206/data/P1206_1.out b/problem/P1206/data/P1206_1.out new file mode 100644 index 00000000..b9e227c9 --- /dev/null +++ b/problem/P1206/data/P1206_1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88a4505153f131552de3d45243b18c66b18bf159dbf6a22f6ebaf92a3305f2d2 +size 93