結果

問題 No.1519 Diversity
ユーザー ks2mks2m
提出日時 2021-05-28 21:17:16
言語 Java19
(openjdk 21)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 2,753 ms
コンパイル使用メモリ 76,360 KB
実行使用メモリ 46,880 KB
最終ジャッジ日時 2023-08-07 05:24:48
合計ジャッジ時間 7,661 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
40,308 KB
testcase_01 AC 152 ms
40,412 KB
testcase_02 AC 149 ms
40,552 KB
testcase_03 AC 240 ms
42,488 KB
testcase_04 AC 264 ms
46,556 KB
testcase_05 AC 152 ms
40,312 KB
testcase_06 AC 284 ms
46,492 KB
testcase_07 AC 170 ms
40,584 KB
testcase_08 AC 224 ms
41,548 KB
testcase_09 AC 242 ms
42,508 KB
testcase_10 AC 265 ms
43,636 KB
testcase_11 AC 152 ms
40,344 KB
testcase_12 AC 277 ms
46,880 KB
testcase_13 AC 287 ms
46,548 KB
testcase_14 AC 286 ms
46,812 KB
testcase_15 AC 284 ms
46,824 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