結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
61,148 KB
testcase_01 AC 100 ms
52,272 KB
testcase_02 AC 127 ms
56,032 KB
testcase_03 AC 140 ms
57,036 KB
testcase_04 AC 144 ms
56,848 KB
testcase_05 AC 142 ms
56,788 KB
testcase_06 AC 129 ms
56,028 KB
testcase_07 AC 265 ms
57,408 KB
testcase_08 AC 272 ms
56,936 KB
testcase_09 AC 275 ms
57,280 KB
testcase_10 AC 262 ms
57,048 KB
testcase_11 AC 273 ms
56,908 KB
testcase_12 AC 1,363 ms
59,196 KB
testcase_13 AC 1,299 ms
59,324 KB
testcase_14 AC 1,377 ms
59,020 KB
testcase_15 AC 1,347 ms
58,176 KB
testcase_16 AC 1,312 ms
57,940 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.ArrayDeque;
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);
		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;
				}
			}
			System.out.println(ans);
		}
		
	}
	
	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}

0