Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define task "PYTHAGORE"
- #include <iostream>
- #include <cstdio>
- #include <cmath>
- using namespace std;
- using ll = long long;
- using ld = long double;
- constexpr int N = 5e3 + 5;
- int cnt[N];
- void Prepare()
- {
- for (int a = 1; a < N; ++a)
- for (int b = a + 1; a + b < N; ++b)
- {
- int c = sqrt(a * a + b * b);
- if (c * c == a * a + b * b && a + b + c < N)
- ++cnt[a + b + c];
- }
- }
- void Solve()
- {
- int t;
- cin >> t;
- while (t--)
- {
- int p;
- cin >> p;
- cout << cnt[p] << "\n";
- }
- }
- int32_t main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- Prepare();
- Solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement