結果

問題 No.864 四方演算
ユーザー tentententen
提出日時 2021-05-12 12:14:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 77 ms / 1,000 ms
コード長 1,372 bytes
コンパイル時間 3,307 ms
コンパイル使用メモリ 77,160 KB
実行使用メモリ 54,032 KB
最終ジャッジ日時 2023-10-24 00:47:45
合計ジャッジ時間 7,056 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,440 KB
testcase_01 AC 77 ms
53,456 KB
testcase_02 AC 73 ms
53,456 KB
testcase_03 AC 73 ms
54,024 KB
testcase_04 AC 76 ms
54,028 KB
testcase_05 AC 71 ms
53,600 KB
testcase_06 AC 77 ms
54,016 KB
testcase_07 AC 74 ms
53,464 KB
testcase_08 AC 73 ms
54,016 KB
testcase_09 AC 70 ms
51,548 KB
testcase_10 AC 71 ms
53,444 KB
testcase_11 AC 65 ms
53,436 KB
testcase_12 AC 74 ms
54,028 KB
testcase_13 AC 75 ms
54,032 KB
testcase_14 AC 66 ms
54,004 KB
testcase_15 AC 77 ms
53,460 KB
testcase_16 AC 75 ms
53,524 KB
testcase_17 AC 76 ms
53,460 KB
testcase_18 AC 74 ms
53,600 KB
testcase_19 AC 71 ms
53,544 KB
testcase_20 AC 77 ms
54,020 KB
testcase_21 AC 75 ms
53,596 KB
testcase_22 AC 73 ms
53,460 KB
testcase_23 AC 59 ms
53,452 KB
testcase_24 AC 71 ms
53,456 KB
testcase_25 AC 68 ms
53,608 KB
testcase_26 AC 73 ms
53,456 KB
testcase_27 AC 56 ms
53,432 KB
testcase_28 AC 54 ms
53,444 KB
testcase_29 AC 56 ms
53,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long n = sc.nextLong();
        long k = sc.nextLong();
        long ans = 0;
        for (long i = 2; i <= Math.sqrt(k); i++) {
            if (k % i == 0) {
                long tmp = getCount(i, n) * getCount(k / i, n);
                if (i * i < k) {
                    tmp *= 2;
                }
                ans += tmp;
            }
        }
        System.out.println(ans);
    }
    
    static long getCount(long x, long n) {
        if (x == 1 || x > 2 * n) {
            return 0;
        } else if (x <= n) {
            return x - 1;
        } else {
            return n - (x - n) + 1;
        }
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0