結果
問題 | No.1593 Perfect Distance |
ユーザー |
![]() |
提出日時 | 2021-07-09 22:17:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 106 ms / 2,000 ms |
コード長 | 738 bytes |
コンパイル時間 | 2,152 ms |
コンパイル使用メモリ | 200,060 KB |
最終ジャッジ日時 | 2025-01-22 22:03:15 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; using ll = long long; constexpr long long MOD = 1000000007; constexpr long long MOD2 = 998244353; constexpr long long INF = 1LL << 60; const long double PI = acosl(-1.0); constexpr long double EPS = 1e-11; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main(){ ll N; cin >> N; map<ll, ll> mp; ll ans = 0; for (ll i = 1; i < N; i++) mp[i * i]++; for (ll i = 1; i < N;i++){ if (mp.count(N * N - i * i)) { ans++; } } cout << ans << endl; }