結果

問題 No.1895 Mod 2
ユーザー masayamatumasayamatu
提出日時 2022-06-25 12:01:20
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,616 bytes
コンパイル時間 10,958 ms
コンパイル使用メモリ 166,716 KB
実行使用メモリ 188,128 KB
最終ジャッジ日時 2024-04-26 18:13:43
合計ジャッジ時間 13,500 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
30,204 KB
testcase_01 AC 135 ms
34,560 KB
testcase_02 AC 131 ms
34,304 KB
testcase_03 AC 149 ms
34,036 KB
testcase_04 AC 127 ms
34,048 KB
testcase_05 AC 139 ms
34,688 KB
testcase_06 AC 141 ms
34,688 KB
testcase_07 AC 137 ms
34,560 KB
testcase_08 AC 132 ms
34,176 KB
testcase_09 AC 132 ms
34,048 KB
testcase_10 AC 131 ms
33,408 KB
testcase_11 AC 137 ms
188,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (97 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
//using static CompLib.CompLib;
//using DataStructure;

namespace atcoder
{
    class Program
    {
        const int intMax = 1000000000;
        const long longMax = 2000000000000000000;
        static void Main(string[] args)
        {
            int T = int.Parse(Console.ReadLine());
            while (T-- > 0)
            {
                var LR = Console.ReadLine().Split().Select(long.Parse).ToArray();
                Console.WriteLine(solve(LR[0], LR[1]));
            }
            long solve(long l, long r)
            {
                long check(long x)
                {
                    if (x == 0) return 0;
                    long ok = 0;
                    long ng = 1000000001;
                    while (Math.Abs(ok - ng) > 1)
                    {
                        long mid = (ok + ng) / 2;
                        if (mid * mid <= x) ok = mid;
                        else ng = mid;
                    }
                    long ret = ok;
                    ok = 0;
                    ng = 1000000001;
                    while (Math.Abs(ok - ng) > 1)
                    {
                        long mid = (ok + ng) / 2;
                        if (2 * mid * mid <= x) ok = mid;
                        else ng = mid;
                    }
                    ret += ok;
                    return ret;
                }
                long ret = check(r) - check(l - 1);
                return ret % 2;
            }
        }
    }
}
0