結果
| 問題 | No.1593 Perfect Distance |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2021-07-11 22:10:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 843 bytes |
| 記録 | |
| コンパイル時間 | 738 ms |
| コンパイル使用メモリ | 93,072 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 03:17:06 |
| 合計ジャッジ時間 | 1,480 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1593.cc: No.1593 Perfect Distance - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 200000;
/* typedef */
typedef long long ll;
/* global variables */
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
ll nn = (ll)n * n;
// sqrt(x^2+y^2)=n -> x^2+y^2=n^2 -> y^2=n^2-x^2
int cnt = 0;
for (int x = 1; x < n; x++) {
ll yy = nn - (ll)x * x;
int y = sqrt(yy + 0.5);
if ((ll)y * y == yy) cnt++;
}
printf("%d\n", cnt);
return 0;
}
tnakao0123