結果

問題 No.1200 お菓子配り-3
ユーザー Y17
提出日時 2020-08-28 22:40:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 167,184 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-14 16:13:16
合計ジャッジ時間 28,525 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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; }

void fast_input_init(){
	ios::sync_with_stdio(false);
	cin.tie(0);
}

int yta();

signed main(){
	fast_input_init();
	int s;
	cin >> 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(){
	cin >> x >> y;

	int ans = 0;
	for(int i = 1;i*i <= x+y;i++){
		if((x+y)%i == 0){
			ans += valid(i-1);
			if(i*i < x+y) ans += valid((x+y)/i-1);
		}
	}
	cout << ans << endl;
	return 0;
}
0