結果
| 問題 | 
                            No.1895 Mod 2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-06-25 12:01:20 | 
| 言語 | C#  (.NET 8.0.404)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 135 ms / 2,000 ms | 
| コード長 | 1,616 bytes | 
| コンパイル時間 | 8,103 ms | 
| コンパイル使用メモリ | 167,340 KB | 
| 実行使用メモリ | 189,640 KB | 
| 最終ジャッジ日時 | 2024-11-14 08:06:17 | 
| 合計ジャッジ時間 | 10,500 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 11 | 
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (101 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/
ソースコード
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;
            }
        }
    }
}