結果

問題 No.1200 お菓子配り-3
ユーザー 37zigen37zigen
提出日時 2020-08-29 11:31:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 938 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 79,144 KB
実行使用メモリ 71,416 KB
最終ジャッジ日時 2024-04-27 01:03:47
合計ジャッジ時間 27,228 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 108 ms
53,520 KB
testcase_02 WA -
testcase_03 AC 135 ms
53,980 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 99 ms
52,556 KB
testcase_28 AC 2,276 ms
68,932 KB
testcase_29 AC 1,901 ms
70,060 KB
testcase_30 AC 1,869 ms
70,028 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	final long MOD=(long)1e9+7;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int S=sc.nextInt();
		while (S-->0) {
			long ans=0;
			long x=sc.nextLong();
			long y=sc.nextLong();
			if (x==y) ans=x-1;
			ArrayList<Long> divs=new ArrayList<>();
			for (long div=3;div*div<=x+y;div+=2) {
				if ((x+y)%div!=0) continue;
				divs.add(div);
				if (div*div!=x+y) {
					divs.add((x+y)/div);
				}
			}
			for (long d:divs) {
				long a=d-1;
				long bc=(x+y)/d;
				long b=(x-bc)/(a-1);
				long c=bc-b;
				if (x!=a*b+c || y!=a*c+b || a<=0 || b<=0 || c<=0) continue;
				ans+=1;
			}
			pw.println(ans);
		}
		pw.flush();
	}
	
	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}

0