結果

問題 No.1298 OR XOR
ユーザー uw_yu1rabbituw_yu1rabbit
提出日時 2020-11-27 21:49:19
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,262 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 100,996 KB
実行使用メモリ 24,572 KB
最終ジャッジ日時 2023-10-01 05:18:43
合計ジャッジ時間 3,841 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
22,500 KB
testcase_01 AC 56 ms
24,572 KB
testcase_02 AC 56 ms
22,464 KB
testcase_03 AC 56 ms
22,556 KB
testcase_04 AC 57 ms
20,480 KB
testcase_05 AC 57 ms
24,412 KB
testcase_06 AC 57 ms
22,668 KB
testcase_07 AC 57 ms
22,564 KB
testcase_08 AC 58 ms
22,504 KB
testcase_09 AC 60 ms
22,560 KB
testcase_10 AC 61 ms
22,368 KB
testcase_11 AC 61 ms
22,504 KB
testcase_12 AC 60 ms
22,484 KB
testcase_13 AC 59 ms
22,408 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Int32 n = Int32.Parse(Console.ReadLine());
            Int32 pt = 1;
            var st = new HashSet<Int32>();
            st.Add(pt);
            for (Int32 i = 0; i < 30; i++)
            {
                pt *= 2;
                st.Add(pt);
            }

            if (st.Contains(n))
            {
                Console.WriteLine("-1 -1 -1");
            }
            else
            {
                var a = n;
                var bit = new List<Int32>();
                while (n != 0)
                {
                    bit.Add(n % 2);
                    n /= 2;
                }

                pt = 1;
                for (Int32 i = 0; i < bit.Count; i++)
                {
                    if (bit[i] == 1)
                    {
                        break;
                    }

                    pt *= 2;
                }
                Console.Write(a);
                Console.Write(" ");
                Console.Write(pt);
                Console.Write(" ");
                Console.WriteLine(a - pt);
            }
        }
    }
}
0