結果

問題 No.1200 お菓子配り-3
ユーザー Y17Y17
提出日時 2020-08-28 22:57:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 765 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 163,764 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-09 09:44:51
合計ジャッジ時間 17,643 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 3 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 13 ms
4,380 KB
testcase_08 AC 13 ms
4,384 KB
testcase_09 AC 12 ms
4,384 KB
testcase_10 AC 12 ms
4,380 KB
testcase_11 AC 11 ms
4,380 KB
testcase_12 AC 101 ms
4,380 KB
testcase_13 AC 104 ms
4,380 KB
testcase_14 AC 106 ms
4,380 KB
testcase_15 AC 106 ms
4,380 KB
testcase_16 AC 104 ms
4,380 KB
testcase_17 AC 374 ms
4,384 KB
testcase_18 AC 543 ms
4,384 KB
testcase_19 AC 126 ms
4,380 KB
testcase_20 AC 1,044 ms
4,384 KB
testcase_21 AC 1,029 ms
4,384 KB
testcase_22 AC 1,240 ms
4,384 KB
testcase_23 AC 1,056 ms
4,384 KB
testcase_24 AC 1,037 ms
4,380 KB
testcase_25 AC 1,046 ms
4,380 KB
testcase_26 AC 1,048 ms
4,380 KB
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 828 ms
4,380 KB
testcase_29 AC 2,322 ms
4,380 KB
testcase_30 AC 2,322 ms
4,384 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int yta();

signed main(){
	int s;
	scanf("%lld", &s);
	while(s--) yta();

	return 0;
}

int x, y;
inline int valid(int a){
	if(a == 0) return 0;
	int sita = a*a-1;
	int ue = a*x-y;
	if(sita == 0 || ue <= 0 || ue%sita != 0) return 0;
	int b = ue/sita; 
	if(x-a*b <= 0) return 0;
	return 1;
}

int yta(){
	scanf("%lld %lld", &x, &y);

	int ans = 0;
	for(int i = 1;i*i <= abs(x-y);i++){
		if(abs(x-y)%i == 0){
			ans += valid(i+1);
			if(i*i < x+y) ans += valid(abs(x-y)/i+1);
		}
	}
	printf("%lld\n", ans);
	return 0;
}
0