結果

問題 No.1089 三変数方程式
ユーザー tentententen
提出日時 2022-09-14 08:42:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,368 bytes
コンパイル時間 2,618 ms
コンパイル使用メモリ 74,048 KB
実行使用メモリ 50,708 KB
最終ジャッジ日時 2023-08-21 07:49:41
合計ジャッジ時間 4,616 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,232 KB
testcase_01 AC 42 ms
49,760 KB
testcase_02 AC 42 ms
49,340 KB
testcase_03 AC 52 ms
50,516 KB
testcase_04 AC 43 ms
49,304 KB
testcase_05 AC 53 ms
50,448 KB
testcase_06 AC 48 ms
49,392 KB
testcase_07 AC 44 ms
49,380 KB
testcase_08 AC 52 ms
50,564 KB
testcase_09 AC 42 ms
49,424 KB
testcase_10 AC 52 ms
50,708 KB
testcase_11 AC 48 ms
49,284 KB
testcase_12 AC 52 ms
50,416 KB
testcase_13 AC 48 ms
49,308 KB
testcase_14 AC 52 ms
50,600 KB
testcase_15 AC 54 ms
50,556 KB
testcase_16 AC 52 ms
50,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        long ans = 0;
        for (int i = 0; i + i + i<= n; i++) {
            for (int j = i; j + i + j <= n; j++) {
                int k = n - i - j;
                if (i == j && j == k) {
                    ans += 1;
                } else if (i == j || j == k) {
                    ans += 3;
                } else {
                    ans += 6;
                }
            }
        }
        System.out.println(ans);
    }
}
    
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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