結果

問題 No.814 ジジ抜き
ユーザー Tomohiko HasegawaTomohiko Hasegawa
提出日時 2019-04-14 00:19:25
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,399 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 65,780 KB
実行使用メモリ 28,848 KB
最終ジャッジ日時 2023-10-13 14:39:23
合計ジャッジ時間 30,629 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
20,832 KB
testcase_01 AC 52 ms
20,904 KB
testcase_02 AC 55 ms
20,712 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.yukicoder
{
    class _814
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long res = 0;
            for(int i = 0; i < n; i++)
            {
                long[] kld = ReadLongs();
                long k = kld[0];
                long l = kld[1];
                int d = (int)kld[2];
                long xor = 0;
                long one = 1;
                for (int j = 0; j < d; j++)
                {
                    if ((l & (one << j)) > 0)
                    {
                        if (k % 2 == 1) xor += (one << j);
                    }
                }
                long unused = (l >> d) - 1;
                long shift = (l >> d) + k - 1;
                for (int j = d; j < 61; j++)
                {
                    long div = (one << (j - d + 1));
                    long cnt = (shift / div) * div / 2;
                    if (shift % div >= div / 2) {
                        cnt += shift % div - div / 2 + 1;
                    }
                    if (unused >= 0)
                    {
                        cnt -= (unused / div) * div / 2;
                        if (unused % div >= div / 2)
                        {
                            cnt -= unused % div - div / 2 + 1;
                        }
                    }
                    if (cnt%2>0) xor += (1<<j);
                }
                res ^=xor;
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}
0