結果

問題 No.2392 二平方和
ユーザー Swapnil AdsulSwapnil Adsul
提出日時 2023-07-28 22:44:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 5,691 bytes
コンパイル時間 2,260 ms
コンパイル使用メモリ 165,516 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 06:42:12
合計ジャッジ時間 2,713 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// Problem: D. Circle Game
// Contest: Codeforces - Codeforces Round 685 (Div. 2)
// URL: https://codeforces.com/problemset/problem/1451/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Author: Swapnil Adsul
// Institute: Pune Institute of Computer Technology, Pune


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long
#define finout() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#include "limits.h"
#define find_max *max_element
#define Im INT_MAX
#define IM  INT_MIN
#define pie 3.14159265359
#define sz(x) ((ll)(x).size())
#define in(k,a) for(auto &k : a)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define acc(a) accumulate(all(a),0)
#define disp(a) in(k,a){ cout<<k<<' ';} cout<<endl
// #define invec(a,n) vector<int>a(n); rep(i,0,n) cin>>a[i]
#define vecd(v) int xyz; cin>>xyz; v.pb(xyz);
//////////////////map/////////////////////

#define mii map<int,int>
#define mll map<long long,long long>
#define mss map<string,string>
#define msi map<string,int>
#define mis map<int,string>
#define msl map<string,long long>
#define mls map<long long,string>
#define ff first
#define ss second
///////////////////sorting of map<int,vector<int>>///////////////////////////
//map<int, vector<int> >::iterator it;
//    for (it = mp.begin(); it != mp.end(); ++it) {
//        sort(it->second.begin(), it->second.end());
//   }
/////////////////////vector/////////////////////////
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vpl vector<pair<long long,long long>>
#define pb push_back
#define pp pop_back
#define sv(arr) sort(arr.begin(),arr.end())
#define rv(arr) reverse(arr.begin(),arr.end())

    //std::vector<int>::iterator upper1, upper2;
  
    // std :: upper_bound
    //upper1 = std::upper_bound(v.begin(), v.end(), 35);
    //upper2 = std::upper_bound(v.begin(), v.end(), 45);
  
    //std::cout << "\nupper_bound for element 35 is at position : " 
     //         << (upper1 - v.begin());
    //std::cout << "\nupper_bound for element 45 is at position : "
    //          << (upper2 - v.begin());
///////////////////////power (log(n))////////////////////////
double myPow(double x, int n) {
  double ans = 1.0;
  long long nn = n;
  if (nn < 0) nn = -1 * nn;
  while (nn) {
    if (nn % 2) {
      ans = ans * x;
      nn = nn - 1;
    } else {
      x = x * x;
      nn = nn / 2;
    }
  }
  if (n < 0) ans = (double)(1.0) / (double)(ans);
  return ans;
}
//--------------------------------- SET -----------------------------
#define si set<int>
#define sl set<long long>
//#define ss set<string>
#define mst set<int>
//st.insert()
//for(auto i=st.begin();i!=st.end();)
//   (*it)
//   st.erase(x)
//   st.find(*it)
//--------------------------------- pair -----------------------------
#define pi pair<int,int>
#define pl pair<long long,long long>
#define fi first
#define se second
//--------------------------------- string -----------------------------
#define gl(s) getline(cin,s)
#define le(s) s.length()
#define str(p,q) s.erase(p,q)
// from p index q elements to be removed
// to reverse string --> reverse(s.begin(), s.end())
typedef long long ll; //8
typedef long double ld; //12
//--------------------------------- loop -----------------------------
#define f(i,x,n) for(int i = x; i < n; i++)
#define rf(i,x,n) for(int i = x; i >= n; i--)
#define fr(i,m) for(auto i:m)
#define read(a)        for(auto& x:a) cin>>x
// void print(int &a){for (auto &x : a){cout<<x<<" ";}cout<<endl;}

const int MOD = 1e9 + 7;;
const int N = 1e6 + 1;

///////////////////////////factorial/////////////////////////////////////
int factorial(int n) {
    int factorial = 1;
    for (int i = 2; i <= n; i++)
        factorial = factorial * i;
    return factorial;
}
int nCr(int n, int r) {
    return factorial(n) / (factorial(r) * factorial(n - r));
}


/*----------------------------------------------------------------------------------------------------*/
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
// void read(int &a){for(auto &x :a){in>>x;}}

int lcm(int a, int b) { return a / __gcd(a, b) * b; }
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
bool prime(int a){if (a == 1){return 0;}for (int i = 2; i <= round(sqrt(a)); ++i){if (a % i == 0){return 0;}}return 1;}
bool isPowerOfTwo(int n) {return ((n==0)?false: (ceil(log2(n)) == floor(log2(n))));}
bool isPerfectSquare(ll x) {return ((x>=0)?((ll)sqrt(x)*(ll)sqrt(x)==x):false);}
/*----------------------------------------------------------------------------------------------------*/
//-------------------------------------------------------------------------
ll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
ll mod_div(ll a, ll b, ll m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;}
//--------------------------------------------------------------------------
// is_sorted(a,a+n)
//-------------------------------------------------------------
 
void test(){
	int n;cin>>n;
	int i=1;
	for(int i=1;i<100007;i++){
		if((n)-(i*i)>=0){
			int p=sqrt((n)-(i*i));
			if(p*p==(n)-(i*i)){cout<<"Yes"<<endl;return;}
		}
		else break;
	}
	cout<<"No"<<endl;
}

signed main(){
    finout();
    int t=1;
    // cin>>t;
    while(t--){
        test();
    }
    return 0;
}
0