結果

問題 No.1200 お菓子配り-3
ユーザー 37zigen37zigen
提出日時 2020-08-30 06:10:19
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,038 bytes
コンパイル時間 2,490 ms
コンパイル使用メモリ 79,356 KB
実行使用メモリ 67,192 KB
最終ジャッジ日時 2024-04-27 01:33:15
合計ジャッジ時間 44,417 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
53,896 KB
testcase_01 AC 126 ms
54,100 KB
testcase_02 AC 167 ms
54,996 KB
testcase_03 AC 164 ms
55,036 KB
testcase_04 AC 164 ms
55,016 KB
testcase_05 AC 162 ms
54,908 KB
testcase_06 AC 161 ms
55,144 KB
testcase_07 AC 199 ms
55,852 KB
testcase_08 AC 209 ms
55,444 KB
testcase_09 AC 221 ms
55,832 KB
testcase_10 AC 190 ms
55,544 KB
testcase_11 AC 192 ms
55,376 KB
testcase_12 AC 525 ms
58,516 KB
testcase_13 AC 592 ms
58,840 KB
testcase_14 AC 506 ms
58,700 KB
testcase_15 AC 538 ms
58,656 KB
testcase_16 AC 533 ms
58,608 KB
testcase_17 AC 1,323 ms
66,364 KB
testcase_18 AC 1,736 ms
66,388 KB
testcase_19 AC 633 ms
58,840 KB
testcase_20 AC 2,838 ms
66,312 KB
testcase_21 AC 2,994 ms
66,320 KB
testcase_22 AC 3,283 ms
66,396 KB
testcase_23 AC 2,795 ms
66,348 KB
testcase_24 AC 2,978 ms
66,624 KB
testcase_25 AC 2,969 ms
66,572 KB
testcase_26 AC 2,849 ms
66,300 KB
testcase_27 AC 140 ms
53,960 KB
testcase_28 TLE -
testcase_29 AC 3,364 ms
67,140 KB
testcase_30 AC 3,270 ms
67,192 KB
testcase_31 AC 121 ms
54,076 KB
testcase_32 AC 118 ms
54,020 KB
権限があれば一括ダウンロードができます

ソースコード

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) {
				x^=y;y^=x;x^=y;
			}
			if (x==y) ans=x-1;//a=1の場合
			ArrayList<Long> divs=new ArrayList<>();
			for (long div=2;div*div<=x+y;++div) {
				if ((x+y)%div!=0) continue;
				divs.add(div);
				if (div*div!=x+y) {
					divs.add((x+y)/div);
				}
			}
			for (long d:divs) {
				if (d==2) continue;
				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