結果

問題 No.864 四方演算
ユーザー tentententen
提出日時 2022-08-12 14:51:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 76 ms / 1,000 ms
コード長 1,487 bytes
コンパイル時間 3,899 ms
コンパイル使用メモリ 77,852 KB
実行使用メモリ 54,080 KB
最終ジャッジ日時 2023-10-24 00:15:48
合計ジャッジ時間 7,220 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
52,532 KB
testcase_01 AC 76 ms
54,064 KB
testcase_02 AC 71 ms
53,648 KB
testcase_03 AC 71 ms
53,512 KB
testcase_04 AC 73 ms
54,064 KB
testcase_05 AC 70 ms
54,072 KB
testcase_06 AC 73 ms
54,080 KB
testcase_07 AC 73 ms
53,508 KB
testcase_08 AC 72 ms
53,596 KB
testcase_09 AC 68 ms
54,072 KB
testcase_10 AC 68 ms
53,596 KB
testcase_11 AC 63 ms
52,772 KB
testcase_12 AC 71 ms
54,068 KB
testcase_13 AC 69 ms
54,080 KB
testcase_14 AC 63 ms
53,500 KB
testcase_15 AC 76 ms
53,508 KB
testcase_16 AC 74 ms
53,504 KB
testcase_17 AC 74 ms
54,072 KB
testcase_18 AC 73 ms
54,064 KB
testcase_19 AC 71 ms
53,452 KB
testcase_20 AC 76 ms
53,656 KB
testcase_21 AC 72 ms
53,512 KB
testcase_22 AC 71 ms
53,656 KB
testcase_23 AC 58 ms
53,488 KB
testcase_24 AC 71 ms
53,512 KB
testcase_25 AC 72 ms
54,060 KB
testcase_26 AC 72 ms
54,064 KB
testcase_27 AC 54 ms
53,496 KB
testcase_28 AC 54 ms
53,488 KB
testcase_29 AC 53 ms
53,492 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 count = getCount(i, n) * getCount(k / i, n);
                if (i * i < k) {
                    count *= 2;
                }
                ans += count;
            }
        }
        System.out.println(ans);
    }
    
    static long getCount(long x, long max) {
        if (x <= max) {
            return x - 1;
        } else if (x <= max * 2) {
            return max - (x - max) + 1;
        } else {
            return 0;
        }
    }
}

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 double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0