結果

問題 No.2493 K-th in L2 with L1
ユーザー PAKACHUPAKACHU
提出日時 2023-10-06 22:13:27
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,204 bytes
コンパイル時間 2,408 ms
コンパイル使用メモリ 134,776 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-10-06 22:13:30
合計ジャッジ時間 2,875 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const long long mod = 998244353;
const ll inf = 1LL << 60;
const int INF = 5e8;

void solve()
{
    int d, k;
    cin >> d >> k;
    vector<int> v;
    if (d == 0) {
        if (k == 1) {
            cout << "Yes" << endl;
            cout << 0 << ' ' << 0 << endl;
        } else {
            cout << "No" << endl;
        }
        return;
    }
    for (int x = 0; x < d; x++) {
        int l = 0, r = 0;
        for (int j = 0; j < d; j++) {
            if (x * x + (d - x) * (d - x) >= j * j + (d - j) * (d - j)) {
                r++;
                if (x * x + (d - x) * (d - x) > j * j + (d - j) * (d - j)) {
                    l++;
                }
            }
        }
        l *= 4;
        r *= 4;
        if (l < k and r >= k) {
            cout << "Yes" << endl;
            cout << x << ' ' << d - x << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main()
{
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        solve();
    }
}
0