結果

問題 No.1200 お菓子配り-3
ユーザー anagohirameanagohirame
提出日時 2020-08-28 22:18:51
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 643 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 197,152 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-08-09 08:56:47
合計ジャッジ時間 7,562 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 5 ms
4,384 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 4 ms
4,384 KB
testcase_11 AC 5 ms
4,512 KB
testcase_12 AC 30 ms
4,384 KB
testcase_13 AC 31 ms
4,384 KB
testcase_14 AC 31 ms
4,380 KB
testcase_15 AC 32 ms
4,380 KB
testcase_16 AC 32 ms
4,380 KB
testcase_17 AC 111 ms
4,384 KB
testcase_18 AC 159 ms
4,384 KB
testcase_19 AC 38 ms
4,380 KB
testcase_20 AC 311 ms
4,380 KB
testcase_21 AC 311 ms
4,380 KB
testcase_22 AC 358 ms
4,380 KB
testcase_23 AC 309 ms
4,384 KB
testcase_24 AC 299 ms
4,380 KB
testcase_25 AC 306 ms
4,384 KB
testcase_26 AC 300 ms
4,380 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 242 ms
4,384 KB
testcase_29 AC 664 ms
4,384 KB
testcase_30 AC 666 ms
4,384 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int s; scanf("%d", &s);
	for (int z = 0; z < s; ++z) {
		int x, y; scanf("%d%d", &x, &y);
		if (x == y) {
			printf("%d\n", x-1);
			continue;
		}
		if (x < y) swap(x, y);
		int ans = 0;
		for (int i = 1; i*i <= x-y; ++i) {
			if ((x-y) % i != 0) continue;
			if ((x+y) % (i+2) == 0) {
				int p = (x-y) / i; int q = (x+y) / (i+2);
				if (p < q and p%2 == q%2) ans++;
			}
			if (i*i == x-y) continue;
			int j = (x-y)/i;
			if ((x+y) % (j+2) == 0) {
				int p = (x-y) / j; int q = (x+y) / (j+2);
				if (p < q and p%2 == q%2) ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}
0