結果
| 問題 |
No.2493 K-th in L2 with L1
|
| コンテスト | |
| ユーザー |
planes
|
| 提出日時 | 2023-11-12 17:13:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 995 bytes |
| コンパイル時間 | 1,461 ms |
| コンパイル使用メモリ | 168,588 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-26 03:02:23 |
| 合計ジャッジ時間 | 1,958 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
ll INF=2e18;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll Q;cin>>Q;
for(ll i=0;i<Q;i++) {
ll D,K;cin>>D>>K;
if(D==0) {
if(K==1) {
cout<<"Yes"<<endl;
cout<<0<<" "<<0<<endl;
}
else cout<<"No"<<endl;
continue;
}
vector<ll> yu(20000+10);
for(ll j=-100;j<=100;j++) {
ll noko=D-abs(j);
if(noko>=0) {
ll x=j;ll y=noko;
yu[x*x+y*y]++;
if(noko>0) yu[x*x+y*y]++;
}
}
for(ll j=1;j<yu.size();j++) {
yu[j]+=yu[j-1];
}
bool ok=false;
for(ll j=-100;j<=100;j++) {
ll noko=D-abs(j);
if(noko>=0) {
ll k=noko*noko+j*j;
if(yu[k-1]<K&&yu[k]>=K) {
cout<<"Yes"<<endl;
cout<<j<<" "<<noko<<endl;
ok=true;
break;
}
}
}
if(!ok) cout<<"No"<<endl;
}
}
planes