結果

問題 No.1200 お菓子配り-3
ユーザー 37zigen37zigen
提出日時 2020-08-29 11:18:30
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 937 bytes
コンパイル時間 2,274 ms
コンパイル使用メモリ 79,168 KB
実行使用メモリ 70,236 KB
最終ジャッジ日時 2024-04-27 01:03:00
合計ジャッジ時間 40,854 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
54,240 KB
testcase_01 AC 111 ms
53,952 KB
testcase_02 AC 143 ms
54,856 KB
testcase_03 AC 145 ms
54,520 KB
testcase_04 AC 155 ms
54,600 KB
testcase_05 AC 154 ms
54,392 KB
testcase_06 AC 153 ms
54,428 KB
testcase_07 AC 176 ms
55,336 KB
testcase_08 AC 175 ms
55,040 KB
testcase_09 AC 192 ms
54,984 KB
testcase_10 AC 172 ms
54,776 KB
testcase_11 AC 175 ms
54,736 KB
testcase_12 AC 464 ms
58,416 KB
testcase_13 AC 493 ms
57,928 KB
testcase_14 AC 482 ms
58,520 KB
testcase_15 AC 502 ms
58,632 KB
testcase_16 AC 442 ms
58,608 KB
testcase_17 AC 1,312 ms
69,000 KB
testcase_18 AC 1,669 ms
69,236 KB
testcase_19 AC 591 ms
58,696 KB
testcase_20 AC 2,688 ms
69,196 KB
testcase_21 AC 2,756 ms
69,152 KB
testcase_22 AC 3,122 ms
69,300 KB
testcase_23 AC 2,664 ms
69,192 KB
testcase_24 AC 2,756 ms
69,328 KB
testcase_25 AC 2,691 ms
69,136 KB
testcase_26 AC 2,655 ms
69,152 KB
testcase_27 AC 109 ms
53,776 KB
testcase_28 TLE -
testcase_29 AC 3,144 ms
70,116 KB
testcase_30 AC 3,117 ms
70,236 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) {
				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