Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- int ans;
- LL p[20];
- LL getHash(int x, int y) {
- LL ret = 0;
- while (x != 0) {
- ret += p[x % 10];
- x /= 10;
- }
- while (y != 0) {
- ret += p[y % 10];
- y /= 10;
- }
- return ret;
- }
- bool judge(int x) {
- LL xHash = getHash(x, 0);
- for (int i = 2; i <= x / i; ++i) {
- if (x % i == 0) {
- if (getHash(i, x / i) == xHash) {
- return true;
- }
- }
- }
- return false;
- }
- int main() {
- #ifdef ExRoc
- freopen("test.txt", "r", stdin);
- #endif // ExRoc
- ios::sync_with_stdio(false);
- p[0] = 1;
- for (int i = 1; i < 10; ++i) {
- p[i] = p[i - 1] * 10;
- }
- for (int i = 1; i <= 1000000; ++i) {
- if (judge(i)) {
- ++ans;
- }
- }
- cout << ans << endl;
- // cout << 590 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement