Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #define _CRT_SECURE_NO_WARNINGS
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <vector>
- #include <stdio.h>
- #include <cmath>
- #include <math.h>
- #include <queue>
- #include <stack>
- #include <climits>
- #include <deque>
- #include <ctime>
- #include <iomanip>
- #include <bitset>
- #include <unordered_map>
- #include <unordered_set>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef unsigned int ui;
- #define mh() make_heap()
- #define poph() pop_heap()
- #define pushh() push_heap()
- #define sor(n) n.begin(), n.end()
- #define rsor(n) n.rbegin(), n.rend()
- #define mp make_pair
- #define files freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)
- #define p(T) pair<T,T>
- #define toch(x) cout.precision(x), cout.setf(ios::fixed)
- #define znac(l) abs(l)/l
- #define IOS ios::sync_with_stdio(false)
- #define IOSB cin.tie(0), cout.tie(0);
- const ll ok = ll(1e9 + 7);
- bool chk2(ll n, ll k)
- {
- for (ll i=1, j=k; i <= j; i++)
- {
- while (i*i + j*j > n)j--;
- if (i*i + j*j == n)return 1;
- }
- return 0;
- }
- bool chk4(ll n)
- {
- ll p = 1;
- for (ll i = 0; i <= 50; i += 2)
- {
- if (n%p != 0)
- break;
- if (((n / p) - 7) % 8 == 0)
- return 1;
- p <<= 2;
- }
- return 0;
- }
- int main()
- {
- IOSB;
- IOS;
- #ifdef TheCompiler
- files;
- #endif
- ll n, k;
- cin >> n;
- k = sqrt(n);
- if (k*k == n)
- {
- cout << 1 << endl;
- return 0;
- }
- if (chk2(n, k))
- {
- cout << 2 << endl;
- return 0;
- }
- if (chk4(n))
- {
- cout << 4 << endl;
- return 0;
- }
- cout << 3;
- return 0;
- }
Add Comment
Please, Sign In to add comment