結果
問題 | No.1593 Perfect Distance |
ユーザー |
![]() |
提出日時 | 2021-07-09 21:46:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 584 bytes |
コンパイル時間 | 1,625 ms |
コンパイル使用メモリ | 169,904 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 15:49:09 |
合計ジャッジ時間 | 2,384 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;//#include <atcoder/all>//using namespace atcoder;using ll=long long;using Graph=vector<vector<int>>;#define MAX 1000000#define MOD 1000000007//#define INF 1000000000#define INF 1000000000000000000int main(){ll N;cin>>N;vector<ll> pows((int)N-1);for(ll i=0;i<N-1;i++){pows[i]=(i+1)*(i+1);}int ans=0;for(ll x=1;x<N;x++){int k=lower_bound(pows.begin(),pows.end(),N*N-x*x)-pows.begin();if(k==(int)N-1){continue;}if(x*x+pows[k]==N*N){ans++;}}cout<<ans<<endl;}