結果

問題 No.2608 Divide into two
ユーザー tentententen
提出日時 2024-01-22 09:55:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 2,264 bytes
コンパイル時間 7,360 ms
コンパイル使用メモリ 89,608 KB
実行使用メモリ 54,004 KB
最終ジャッジ日時 2024-01-22 09:55:31
合計ジャッジ時間 3,704 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
53,984 KB
testcase_01 AC 52 ms
53,992 KB
testcase_02 AC 57 ms
54,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int t = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        while (t-- > 0) {
            int n = sc.nextInt();
            if (n % 4 == 1 || n % 4 == 2) {
                sb.append("-1");
            } else if (n % 4 == 0) {
                for (int i = 0; i < n; i++) {
                    if (i % 4 == 0 || i % 4 == 3) {
                        sb.append("1");
                    } else {
                        sb.append("0");
                    }
                }
            } else {
                for (int i = 0; i < n; i++) {
                    if (i % 4 == 0 || i % 4 == 1) {
                        sb.append("1");
                    } else {
                        sb.append("0");
                    }
                }
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0