結果
問題 | No.690 E869120 and Constructing Array 4 |
ユーザー |
![]() |
提出日時 | 2021-03-02 19:21:23 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 136 ms / 1,000 ms |
コード長 | 1,083 bytes |
コンパイル時間 | 2,553 ms |
コンパイル使用メモリ | 78,728 KB |
実行使用メモリ | 41,660 KB |
最終ジャッジ日時 | 2024-10-03 01:56:41 |
合計ジャッジ時間 | 6,164 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
import java.util.*;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int k = sc.nextInt();ArrayList<Path> ans = new ArrayList<>();for (int i = 1; i <= 30; i++) {for (int j = i + 1; j <= 31; j++) {ans.add(new Path(i, j));}}for (int i = 29; i >= 0; i--) {if (k >= (1 << i)) {ans.add(new Path(i + 2, 32));k -= (1 << i);}}StringBuilder sb = new StringBuilder();sb.append("32 ").append(ans.size()).append("\n");for (Path p : ans) {sb.append(p).append("\n");}System.out.print(sb);}static class Path {int from;int to;public Path(int from, int to) {this.from = from;this.to = to;}public String toString() {return new StringBuilder().append(from).append(" ").append(to).toString();}}}