結果

問題 No.1200 お菓子配り-3
ユーザー furafura
提出日時 2020-09-09 17:27:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 197,880 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 04:02:35
合計ジャッジ時間 12,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 8 ms
4,384 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 8 ms
4,380 KB
testcase_12 AC 56 ms
4,380 KB
testcase_13 AC 58 ms
4,380 KB
testcase_14 AC 58 ms
4,380 KB
testcase_15 AC 58 ms
4,380 KB
testcase_16 AC 57 ms
4,376 KB
testcase_17 AC 204 ms
4,384 KB
testcase_18 AC 294 ms
4,380 KB
testcase_19 AC 68 ms
4,376 KB
testcase_20 AC 560 ms
4,376 KB
testcase_21 AC 562 ms
4,380 KB
testcase_22 AC 665 ms
4,376 KB
testcase_23 AC 559 ms
4,380 KB
testcase_24 AC 559 ms
4,376 KB
testcase_25 AC 559 ms
4,380 KB
testcase_26 AC 565 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 927 ms
4,380 KB
testcase_29 AC 680 ms
4,380 KB
testcase_30 AC 681 ms
4,380 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

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>0) {
			lint D=a*a-1;
			lint b=a*x-y,c=-x+a*y;
			if(D!=0 && b%D==0 && c%D==0){
				b/=D;
				c/=D;
				if(b>0 && c>0) ans++;
			}
		}
	}
	printf("%d\n",ans);
}

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