結果

問題 No.1200 お菓子配り-3
ユーザー 37zigen37zigen
提出日時 2020-08-30 05:49:44
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 991 bytes
コンパイル時間 2,786 ms
コンパイル使用メモリ 79,368 KB
実行使用メモリ 67,000 KB
最終ジャッジ日時 2024-04-27 01:32:11
合計ジャッジ時間 35,569 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,172 KB
testcase_01 AC 136 ms
53,964 KB
testcase_02 AC 169 ms
54,644 KB
testcase_03 AC 173 ms
54,992 KB
testcase_04 AC 169 ms
55,020 KB
testcase_05 AC 193 ms
55,576 KB
testcase_06 AC 177 ms
55,384 KB
testcase_07 AC 201 ms
55,624 KB
testcase_08 AC 213 ms
55,672 KB
testcase_09 AC 233 ms
55,600 KB
testcase_10 AC 228 ms
55,888 KB
testcase_11 AC 209 ms
55,464 KB
testcase_12 AC 476 ms
58,136 KB
testcase_13 AC 533 ms
58,892 KB
testcase_14 AC 487 ms
58,632 KB
testcase_15 AC 522 ms
58,716 KB
testcase_16 AC 511 ms
56,748 KB
testcase_17 AC 1,236 ms
66,260 KB
testcase_18 AC 1,454 ms
66,268 KB
testcase_19 AC 525 ms
58,624 KB
testcase_20 AC 2,285 ms
66,344 KB
testcase_21 AC 2,363 ms
66,324 KB
testcase_22 AC 2,624 ms
66,400 KB
testcase_23 AC 2,264 ms
66,368 KB
testcase_24 AC 2,257 ms
66,236 KB
testcase_25 AC 2,224 ms
66,388 KB
testcase_26 AC 2,289 ms
66,528 KB
testcase_27 AC 148 ms
54,316 KB
testcase_28 AC 2,475 ms
66,424 KB
testcase_29 AC 1,993 ms
66,980 KB
testcase_30 AC 1,978 ms
67,000 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=Long.parseLong(sc.next());
			long y=Long.parseLong(sc.next());
			if (x==y) ans=x-1;
			ArrayList<Long> divs=new ArrayList<>();
			int add=(x+y)%2==0?1:2;
			for (long div=3;div*div<=x+y;div+=add) {
				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