結果

問題 No.1200 お菓子配り-3
ユーザー 37zigen37zigen
提出日時 2020-08-29 11:07:13
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 888 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 78,212 KB
実行使用メモリ 76,512 KB
最終ジャッジ日時 2024-04-27 01:02:11
合計ジャッジ時間 21,292 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
60,784 KB
testcase_01 AC 105 ms
53,104 KB
testcase_02 AC 144 ms
56,500 KB
testcase_03 AC 133 ms
56,384 KB
testcase_04 AC 145 ms
56,480 KB
testcase_05 AC 140 ms
56,648 KB
testcase_06 AC 141 ms
56,688 KB
testcase_07 AC 266 ms
57,028 KB
testcase_08 AC 264 ms
57,024 KB
testcase_09 AC 256 ms
56,992 KB
testcase_10 AC 256 ms
57,012 KB
testcase_11 AC 268 ms
56,960 KB
testcase_12 AC 1,282 ms
59,080 KB
testcase_13 AC 1,250 ms
59,164 KB
testcase_14 AC 1,342 ms
57,952 KB
testcase_15 AC 1,364 ms
58,040 KB
testcase_16 AC 1,333 ms
57,976 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
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;
			boolean flag=false;
			for (long div=3;div*div<=x+y;++div) {
				for (long d:new long[] {div,(x+y)/div}) {
					if (d*d==x+y) {
						if (flag) continue;
						else flag=true;
					}
					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