結果

問題 No.1593 Perfect Distance
ユーザー Cyclone28Cyclone28
提出日時 2021-07-09 22:27:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 4,540 bytes
コンパイル時間 1,453 ms
コンパイル使用メモリ 164,252 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 09:43:07
合計ジャッジ時間 2,393 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif
#if __cplusplus >= 201703L
#include <any>
#include <charconv>
// #include <execution>
#include <filesystem>
#include <optional>
//#include <memory_resource>
#include <string_view>
#include <variant>
#endif
#if __cplusplus > 201703L
#include <barrier>
#include <bit>
#include <compare>
#include <concepts>
#if __cpp_impl_coroutine
#include <coroutine>
#endif
#include <latch>
#include <numbers>
#include <ranges>
#include <span>
#include <stop_token>
#include <semaphore>
#include <source_location>
#include <syncstream>
#include <version>
#endif
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

//#define int ll

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

#define rep1(i, n) for(ll i = 0; i < (int)(n); i++)
#define rep2(i, a, b) for(ll i = (int)(a); i < (int)(b); i++)
#define rep3(i, a, b, c) for(ll i = (int)(a); i < (int)(b); i+=(int)(c))
#define rrep1(i, n) for(ll i = (int)(n); i >= 0; i--)
#define rrep2(i, a, b) for(ll i = (int)(b); i >= (int)(a); i--)
#define REP(i) for(ll i = 0; ; i++)
#define all(v) (v).begin(), (v).end()

template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }
template<class T> ll sum(const T& a){ return accumulate(all(a), 0LL); }
template<class T> ld dsum(const T& a){ return accumulate(all(a), 0.0L); }

const int MOD = 1000000007;
const int MMOD = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll POW(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll MODPOW(ll a, ll b){ ll ret = 1; while(b){ if(b & 1) ret = ret*a%MOD; a = a*a%MOD; b /= 2;} return ret;}

/*
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
//*/

/*
struct Edge{
  ll to;
  ll we;
  t(ll s, ll t) : to(s), we(t) {}
};
using Graph = vector<vector<Edge>>;
//*/

/*
#include<atcoder/all>
using namespace atcoder;
//*/

/*
ll op(ll a, ll b) { return a+b; }
ll e() { return 0; }
//*/

signed main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll N; cin >> N;
  N *= N;
  ll ans = 0;
  for(ll i = 1; i <= 1000000; i++){
    if(i*i >= N) break;
    ll p = N-i*i;
    ll q = (ll)floor(sqrt((ld)p));
    ans += (q*q==p?1:0);
  }
  cout << ans << endl;
}
0