結果

問題 No.1200 お菓子配り-3
ユーザー furafura
提出日時 2020-09-09 17:30:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 921 ms / 4,000 ms
コード長 504 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 200,376 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 00:22:39
合計ジャッジ時間 10,347 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 7 ms
6,944 KB
testcase_08 AC 8 ms
6,940 KB
testcase_09 AC 8 ms
6,944 KB
testcase_10 AC 7 ms
6,940 KB
testcase_11 AC 8 ms
6,940 KB
testcase_12 AC 56 ms
6,940 KB
testcase_13 AC 58 ms
6,944 KB
testcase_14 AC 58 ms
6,940 KB
testcase_15 AC 57 ms
6,944 KB
testcase_16 AC 58 ms
6,944 KB
testcase_17 AC 204 ms
6,940 KB
testcase_18 AC 292 ms
6,944 KB
testcase_19 AC 69 ms
6,944 KB
testcase_20 AC 560 ms
6,944 KB
testcase_21 AC 561 ms
6,940 KB
testcase_22 AC 664 ms
6,944 KB
testcase_23 AC 558 ms
6,940 KB
testcase_24 AC 560 ms
6,944 KB
testcase_25 AC 557 ms
6,944 KB
testcase_26 AC 563 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 921 ms
6,940 KB
testcase_29 AC 679 ms
6,940 KB
testcase_30 AC 680 ms
6,940 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

void solve(){
	int x,y; scanf("%d%d",&x,&y);

	int ans=0;
	for(int d=1;d*d<=x+y;d++) if((x+y)%d==0) {
		for(lint a:{d-1,(x+y)/d-1}) if(a>=2) {
			lint D=a*a-1;
			lint b=a*x-y,c=-x+a*y;
			if(b%D==0 && c%D==0){
				b/=D;
				c/=D;
				if(b>0 && c>0) ans++;
			}
		}
	}

	// a == 1
	if(x==y) ans+=x-1;

	printf("%d\n",ans);
}

int main(){
	int q; scanf("%d",&q); rep(_,q) solve();
	return 0;
}
0