結果
問題 | No.2608 Divide into two |
ユーザー |
|
提出日時 | 2024-01-19 21:26:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 2,004 ms |
コンパイル使用メモリ | 195,364 KB |
最終ジャッジ日時 | 2025-02-18 20:37:36 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ int N; cin >> N; if((N*(N+1)/2)%2){cout << -1 << endl; continue;} string answer = ""; int goal = (N*(N+1)/4); for(int i=N; i>=1; i--){ if(goal >= i) answer += '1',goal -= i; else answer += '0'; } reverse(answer.begin(),answer.end()); cout << answer << endl; } }