結果

問題 No.1519 Diversity
ユーザー ks2mks2m
提出日時 2021-05-28 21:17:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 291 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 2,482 ms
コンパイル使用メモリ 77,148 KB
実行使用メモリ 48,664 KB
最終ジャッジ日時 2024-04-24 23:34:36
合計ジャッジ時間 7,686 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
42,308 KB
testcase_01 AC 155 ms
42,308 KB
testcase_02 AC 160 ms
42,340 KB
testcase_03 AC 234 ms
43,852 KB
testcase_04 AC 273 ms
46,000 KB
testcase_05 AC 158 ms
42,348 KB
testcase_06 AC 281 ms
48,664 KB
testcase_07 AC 161 ms
42,136 KB
testcase_08 AC 227 ms
42,980 KB
testcase_09 AC 244 ms
44,152 KB
testcase_10 AC 278 ms
45,204 KB
testcase_11 AC 143 ms
42,128 KB
testcase_12 AC 291 ms
48,644 KB
testcase_13 AC 290 ms
48,564 KB
testcase_14 AC 291 ms
48,596 KB
testcase_15 AC 283 ms
48,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int n2 = n / 2;
		List<String> list = new ArrayList<>();
		int x = n - 1;
		for (int i = 1; i <= n2; i++) {
			for (int j = 1; j <= x; j++) {
				list.add(i + " " + (i + j));
			}
			x -= 2;
		}

		PrintWriter pw = new PrintWriter(System.out);
		pw.println(list.size());
		for (String s : list) {
			pw.println(s);
		}
		pw.flush();
	}
}
0