結果
| 問題 | No.1298 OR XOR | 
| コンテスト | |
| ユーザー |  uw_yu1rabbit | 
| 提出日時 | 2020-11-27 21:49:19 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 29 ms / 2,000 ms | 
| コード長 | 1,262 bytes | 
| コンパイル時間 | 2,648 ms | 
| コンパイル使用メモリ | 113,372 KB | 
| 実行使用メモリ | 27,552 KB | 
| 最終ジャッジ日時 | 2024-07-26 12:13:59 | 
| 合計ジャッジ時間 | 3,079 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 13 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
            }
        }
    }
}
            
            
            
        