結果

問題 No.2493 K-th in L2 with L1
ユーザー otamay6otamay6
提出日時 2023-10-15 23:31:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 68,596 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-15 23:31:35
合計ジャッジ時間 1,411 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>

int main(void){
	int q;std::cin>>q;
	while(q--){
		int d,k;
		std::cin>>d>>k;
		if(d==0&&k>1){
			std::cout << "No" << std::endl;
			continue;
		}
		int x = d/2,y = d-x;
		while(true){
			if(x*2==d || x==0){
				k -= 4;
			}
			else {
				k -= 8;
			}
			if(k<=0){
				break;
			}
			x-=1;y+=1;
		}
		if(x<0||y>d){
			std::cout << "No" << std::endl;
		}
		else{
			std::cout << "Yes\n" << x << " " << y << std::endl;
		}
	}
}
0