結果

問題 No.864 四方演算
ユーザー GrenacheGrenache
提出日時 2019-08-16 21:42:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 1,000 ms
コード長 1,606 bytes
コンパイル時間 6,279 ms
コンパイル使用メモリ 78,532 KB
実行使用メモリ 57,836 KB
最終ジャッジ日時 2023-10-26 02:44:20
合計ジャッジ時間 11,346 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
54,912 KB
testcase_01 AC 141 ms
57,740 KB
testcase_02 AC 136 ms
57,324 KB
testcase_03 AC 135 ms
57,628 KB
testcase_04 AC 139 ms
57,400 KB
testcase_05 AC 133 ms
55,756 KB
testcase_06 AC 140 ms
57,328 KB
testcase_07 AC 140 ms
57,316 KB
testcase_08 AC 134 ms
57,576 KB
testcase_09 AC 121 ms
56,368 KB
testcase_10 AC 121 ms
56,408 KB
testcase_11 AC 130 ms
57,324 KB
testcase_12 AC 135 ms
57,836 KB
testcase_13 AC 130 ms
57,480 KB
testcase_14 AC 120 ms
56,432 KB
testcase_15 AC 131 ms
56,364 KB
testcase_16 AC 140 ms
57,564 KB
testcase_17 AC 138 ms
57,264 KB
testcase_18 AC 136 ms
57,592 KB
testcase_19 AC 135 ms
57,552 KB
testcase_20 AC 139 ms
57,436 KB
testcase_21 AC 140 ms
57,812 KB
testcase_22 AC 138 ms
57,588 KB
testcase_23 AC 128 ms
57,272 KB
testcase_24 AC 129 ms
56,816 KB
testcase_25 AC 133 ms
57,352 KB
testcase_26 AC 126 ms
56,852 KB
testcase_27 AC 122 ms
57,604 KB
testcase_28 AC 125 ms
57,252 KB
testcase_29 AC 113 ms
56,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Scanner;


public class Main_yukicoder864 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long n = sc.nextLong();
		long k = sc.nextLong();

		long ans = 0;
		for (int i = 1; (long)i * i <= k; i++) {
			if (k % i != 0) {
				continue;
			}
			
			ans += f(i, n) * f(k / i, n);
			if (i != k / i) {
				ans += f(k/ i, n) * f(i, n);
			}
		}
		
		pr.println(ans);
	}

	private static long f(long i, long n) {
		if (i > 2 * n) {
			return 0;
		}

		long tmp = Math.min(n, i - 1);
		long tmp1 = Math.max(1, i - tmp);
		
		return tmp - tmp1 + 1;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
		
		void printInts(int... a) {
			StringBuilder sb = new StringBuilder(32);
			for (int i = 0, size = a.length; i < size; i++) {
				if (i > 0) {
					sb.append(' ');
				}
				sb.append(a[i]);
			}

			println(sb);
		}
		
		void printLongs(long... a) {
			StringBuilder sb = new StringBuilder(64);
			for (int i = 0, size = a.length; i < size; i++) {
				if (i > 0) {
					sb.append(' ');
				}
				sb.append(a[i]);
			}

			println(sb);
		}
		
		void printStrings(String... a) {
			StringBuilder sb = new StringBuilder(32);
			for (int i = 0, size = a.length; i < size; i++) {
				if (i > 0) {
					sb.append(' ');
				}
				sb.append(a[i]);
			}

			println(sb);
		}
	}
}
0