結果
問題 | No.2608 Divide into two |
ユーザー | tnakao0123 |
提出日時 | 2024-01-20 02:19:20 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 657 bytes |
コンパイル時間 | 365 ms |
コンパイル使用メモリ | 41,920 KB |
実行使用メモリ | 6,676 KB |
最終ジャッジ日時 | 2024-01-20 02:19:21 |
合計ジャッジ時間 | 996 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,676 KB |
testcase_01 | AC | 2 ms
6,676 KB |
testcase_02 | AC | 2 ms
6,676 KB |
ソースコード
/* -*- coding: utf-8 -*- * * 2608.cc: No.2608 Divide into two - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 100; /* typedef */ /* global variables */ int as[MAX_N]; /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d", &n); int s = n * (n + 1) / 2; if (s & 1) { puts("-1"); continue; } int t = s / 2; fill(as, as + n, 0); for (int i = n; i >= 1; i--) if (t >= i) { as[i - 1] = 1; t -= i; } for (int i = 0; i < n; i++) printf("%d", as[i]); putchar('\n'); } return 0; }