結果
問題 | No.942 プレゼント配り |
ユーザー | neko_the_shadow |
提出日時 | 2019-12-05 22:11:21 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,793 bytes |
コンパイル時間 | 2,876 ms |
コンパイル使用メモリ | 89,064 KB |
実行使用メモリ | 92,840 KB |
最終ジャッジ日時 | 2023-08-24 17:09:10 |
合計ジャッジ時間 | 8,371 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 61 ms
50,752 KB |
testcase_01 | AC | 293 ms
70,600 KB |
testcase_02 | AC | 43 ms
49,732 KB |
testcase_03 | AC | 44 ms
49,900 KB |
testcase_04 | AC | 288 ms
64,664 KB |
testcase_05 | AC | 298 ms
70,364 KB |
testcase_06 | WA | - |
testcase_07 | AC | 59 ms
50,840 KB |
testcase_08 | AC | 266 ms
62,248 KB |
testcase_09 | AC | 266 ms
62,688 KB |
testcase_10 | AC | 43 ms
49,560 KB |
testcase_11 | AC | 43 ms
50,284 KB |
testcase_12 | AC | 43 ms
49,736 KB |
testcase_13 | AC | 42 ms
49,704 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 59 ms
50,756 KB |
testcase_19 | AC | 44 ms
49,652 KB |
ソースコード
package _0942; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; public class Main { public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException { String[] line = stdin.readLine().split(" "); BigInteger n = new BigInteger(line[0]); BigInteger k = new BigInteger(line[1]); // (n * (n + 1) / 2) % k == 0 if (!n.multiply(n.add(BigInteger.ONE)).divide(BigInteger.valueOf(2L)).remainder(k).equals(BigInteger.ZERO)) { stdout.println("No"); return ; } List<List<Long>> matrix = new ArrayList<>(); for (int i = 0; i < k.intValue(); i++) { matrix.add(new ArrayList<>()); } int x = 0; int dx = 1; for (long i = 1; i <= n.longValue(); i++) { matrix.get(x).add(i); x += dx; if (x == -1) { x = 0; dx = 1; } if (x == k.longValue()) { x = k.intValue() - 1; dx = -1; } } stdout.println("Yes"); for (List<Long> row : matrix) { stdout.println(row.stream().map(Objects::toString).collect(Collectors.joining(" "))); } } public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); PrintWriter stdout = new PrintWriter(System.out, false); new Main().solve(stdin, stdout); stdout.flush(); } }