結果

問題 No.2608 Divide into two
ユーザー heno239heno239
提出日時 2024-02-05 16:49:43
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 83 ms / 1,000 ms
コード長 1,246 bytes
コンパイル時間 12,967 ms
コンパイル使用メモリ 158,680 KB
実行使用メモリ 181,780 KB
最終ジャッジ日時 2024-02-05 16:49:58
合計ジャッジ時間 14,341 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
32,548 KB
testcase_01 AC 77 ms
32,932 KB
testcase_02 AC 83 ms
181,780 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (101 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System.Collections;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

internal class Program
{
    private const long mod = 998244353;
    

    public static void Main(string[] args)
    {
        var t = int.Parse(Console.ReadLine());
        while (t-->0)
        {
            int n = int.Parse(Console.ReadLine());
            int sum = n * (n + 1) / 2;
            if (sum % 2!=0)
            {
                Console.WriteLine(-1);
            }
            else
            {
                string ans = "";
                int rest = sum / 2;
                for (int i = n; i >= 1; i--)
                {
                    if (rest >= i)
                    {
                        rest -= i;
                        ans += '1';
                    }
                    else
                    {
                        ans += '0';
                    }
                }

                ans = String.Join("", ans.Reverse());
                Console.WriteLine(ans);
            }
        }
    }

    public static List<int> mkar(int n, int val)
    {
        List<int> res = new List<int>(n);
        for(int i=0;i<n;i++)res.Add(val);
        return res;
    }
}
0