結果

問題 No.1184 Hà Nội
ユーザー keymoonkeymoon
提出日時 2020-12-31 21:39:11
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 2,801 bytes
コンパイル時間 5,098 ms
コンパイル使用メモリ 115,196 KB
実行使用メモリ 27,284 KB
最終ジャッジ日時 2024-04-18 03:14:58
合計ジャッジ時間 2,672 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
25,216 KB
testcase_01 AC 25 ms
25,244 KB
testcase_02 AC 26 ms
27,156 KB
testcase_03 AC 23 ms
25,088 KB
testcase_04 AC 23 ms
27,284 KB
testcase_05 AC 23 ms
25,212 KB
testcase_06 AC 24 ms
25,212 KB
testcase_07 AC 24 ms
25,132 KB
testcase_08 AC 23 ms
25,212 KB
testcase_09 AC 26 ms
25,108 KB
testcase_10 AC 26 ms
27,032 KB
testcase_11 AC 25 ms
24,864 KB
testcase_12 AC 25 ms
24,992 KB
testcase_13 AC 24 ms
24,988 KB
testcase_14 AC 24 ms
27,152 KB
testcase_15 AC 26 ms
24,988 KB
testcase_16 AC 25 ms
24,828 KB
testcase_17 AC 26 ms
25,208 KB
testcase_18 AC 24 ms
25,120 KB
testcase_19 AC 24 ms
24,956 KB
testcase_20 AC 27 ms
24,988 KB
testcase_21 AC 24 ms
22,832 KB
testcase_22 AC 23 ms
25,264 KB
testcase_23 AC 24 ms
25,132 KB
testcase_24 AC 24 ms
27,140 KB
testcase_25 AC 23 ms
27,132 KB
testcase_26 AC 23 ms
25,248 KB
testcase_27 AC 22 ms
23,220 KB
testcase_28 AC 23 ms
25,116 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(long.Parse).ToArray();
        Console.WriteLine(Power(2, (ab[0] + ab[1] - 1) / ab[1]) - 1);
    }

    static ModInt Power(ModInt n, long m)
    {
        ModInt pow = n;
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= pow;
            pow *= pow;
            m >>= 1;
        }
        return res;
    }
}

struct ModInt
{
    public const int Mod = 998244353;
    const long POSITIVIZER = ((long)Mod) << 31;
    long Data;
    public ModInt(long data) { if ((Data = data % Mod) < 0) Data += Mod; }
    public static implicit operator long(ModInt modInt) => modInt.Data;
    public static implicit operator ModInt(long val) => new ModInt(val);
    public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod };
    public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
    public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; }
    public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod };
    public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
    public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; }
    public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);
    public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod };
    public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod };
    public static bool operator ==(ModInt a, ModInt b) => a.Data == b.Data;
    public static bool operator !=(ModInt a, ModInt b) => a.Data != b.Data;
    public override string ToString() => Data.ToString();
    public override bool Equals(object obj) => (ModInt)obj == this;
    public override int GetHashCode() => (int)Data;
    static long GetInverse(long a)
    {
        long div, p = Mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
        while (true)
        {
            if (p == 1) return x2 + Mod; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p;
            if (a == 1) return x1 + Mod; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a;
        }
    }
}
0