結果

問題 No.864 四方演算
ユーザー GrenacheGrenache
提出日時 2019-08-16 21:42:45
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 108 ms / 1,000 ms
コード長 1,606 bytes
コンパイル時間 2,436 ms
使用メモリ 38,220 KB
最終ジャッジ日時 2022-11-24 11:26:30
合計ジャッジ時間 6,567 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 83 ms
37,784 KB
testcase_01 AC 106 ms
37,816 KB
testcase_02 AC 101 ms
37,844 KB
testcase_03 AC 94 ms
37,868 KB
testcase_04 AC 101 ms
37,856 KB
testcase_05 AC 94 ms
37,756 KB
testcase_06 AC 100 ms
37,908 KB
testcase_07 AC 98 ms
37,860 KB
testcase_08 AC 94 ms
37,700 KB
testcase_09 AC 108 ms
37,928 KB
testcase_10 AC 100 ms
37,756 KB
testcase_11 AC 93 ms
37,800 KB
testcase_12 AC 101 ms
37,916 KB
testcase_13 AC 97 ms
37,932 KB
testcase_14 AC 88 ms
37,756 KB
testcase_15 AC 103 ms
37,916 KB
testcase_16 AC 99 ms
37,984 KB
testcase_17 AC 101 ms
37,996 KB
testcase_18 AC 102 ms
38,220 KB
testcase_19 AC 92 ms
37,796 KB
testcase_20 AC 98 ms
37,960 KB
testcase_21 AC 103 ms
38,048 KB
testcase_22 AC 95 ms
37,760 KB
testcase_23 AC 84 ms
37,624 KB
testcase_24 AC 96 ms
37,940 KB
testcase_25 AC 91 ms
37,844 KB
testcase_26 AC 105 ms
38,008 KB
testcase_27 AC 88 ms
37,908 KB
testcase_28 AC 82 ms
37,788 KB
testcase_29 AC 81 ms
37,872 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