結果

問題 No.814 ジジ抜き
ユーザー Tomohiko HasegawaTomohiko Hasegawa
提出日時 2019-04-14 00:37:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 1,827 ms / 3,000 ms
コード長 2,441 bytes
コンパイル時間 966 ms
コンパイル使用メモリ 65,732 KB
実行使用メモリ 29,028 KB
最終ジャッジ日時 2023-10-13 14:42:57
合計ジャッジ時間 30,304 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
18,608 KB
testcase_01 AC 54 ms
18,868 KB
testcase_02 AC 56 ms
20,716 KB
testcase_03 AC 73 ms
20,680 KB
testcase_04 AC 1,304 ms
26,924 KB
testcase_05 AC 1,334 ms
24,960 KB
testcase_06 AC 1,827 ms
26,976 KB
testcase_07 AC 926 ms
26,880 KB
testcase_08 AC 1,756 ms
26,980 KB
testcase_09 AC 1,293 ms
22,960 KB
testcase_10 AC 1,747 ms
26,988 KB
testcase_11 AC 1,821 ms
27,016 KB
testcase_12 AC 854 ms
24,884 KB
testcase_13 AC 909 ms
26,900 KB
testcase_14 AC 1,340 ms
24,996 KB
testcase_15 AC 658 ms
24,852 KB
testcase_16 AC 627 ms
26,896 KB
testcase_17 AC 1,310 ms
26,992 KB
testcase_18 AC 1,150 ms
26,892 KB
testcase_19 AC 1,655 ms
22,928 KB
testcase_20 AC 956 ms
24,924 KB
testcase_21 AC 990 ms
24,948 KB
testcase_22 AC 1,479 ms
26,876 KB
testcase_23 AC 746 ms
29,028 KB
testcase_24 AC 1,323 ms
24,952 KB
testcase_25 AC 1,044 ms
26,904 KB
権限があれば一括ダウンロードができます

ソースコード

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;
                //WriteLine(one << 62);
                for (int j = d; j < 62; 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 += (one<<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