結果
問題 |
No.1593 Perfect Distance
|
ユーザー |
|
提出日時 | 2021-07-10 09:29:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 774 bytes |
コンパイル時間 | 1,604 ms |
コンパイル使用メモリ | 166,428 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-02 01:44:35 |
合計ジャッジ時間 | 2,367 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define repd(i,a,b) for (ll i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) #define all(x) (x).begin(),(x).end() #define SIZE(x) ll(x.size()) 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; } typedef long long ll; const long long INF = 1LL << 60; const long long MOD = 1000000007; typedef pair<int, int> P; int main() { ll N; cin >> N; N *= N; ll ans = 0; for (ll i = 1; i * i < N; i++) { ll x = i * i; ll y = N - x; y = ceil(sqrt(y)); y *= y; if (x + y == N) ans++; } cout << ans << endl; return 0; }