結果

問題 No.1593 Perfect Distance
ユーザー bokusunny
提出日時 2022-01-20 11:13:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 1,708 ms
コンパイル使用メモリ 196,848 KB
最終ジャッジ日時 2025-01-27 13:12:10
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define bokusunny ios::sync_with_stdio(false), cin.tie(nullptr);

void solve() {
  long long N;
  cin >> N;

  set<long long> st;
  for (int i = 1; i <= N; i++) st.insert(1LL * i * i);

  long long ans = 0;
  for (int x = 1; x <= N; x++) {
    ans += (int)st.count(N * N - 1LL * x * x);
  }

  cout << ans << endl;
}

int main() {
  bokusunny;
  solve();

  return 0;
}
0