結果

問題 No.1519 Diversity
ユーザー tentententen
提出日時 2022-08-05 12:52:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,235 bytes
コンパイル時間 1,835 ms
コンパイル使用メモリ 74,248 KB
実行使用メモリ 52,800 KB
最終ジャッジ日時 2023-10-13 11:38:42
合計ジャッジ時間 5,138 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
49,284 KB
testcase_01 AC 42 ms
49,264 KB
testcase_02 AC 40 ms
49,400 KB
testcase_03 AC 77 ms
51,252 KB
testcase_04 AC 90 ms
51,512 KB
testcase_05 AC 40 ms
49,256 KB
testcase_06 AC 100 ms
52,700 KB
testcase_07 AC 43 ms
49,484 KB
testcase_08 AC 60 ms
51,228 KB
testcase_09 AC 81 ms
51,344 KB
testcase_10 AC 94 ms
51,228 KB
testcase_11 AC 40 ms
47,724 KB
testcase_12 AC 95 ms
51,256 KB
testcase_13 AC 98 ms
51,740 KB
testcase_14 AC 99 ms
52,448 KB
testcase_15 AC 102 ms
52,800 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();
        StringBuilder sb = new StringBuilder();
        int count = 0;
        for (int i = 1; i < n - i + 1; i++) {
            for (int j = i + 1; j <= n - i + 1; j++) {
                sb.append(i).append(" ").append(j).append("\n");
                count++;
            }
        }
        System.out.println(count);
        System.out.print(sb);
    }
}

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