結果

問題 No.1184 Hà Nội
ユーザー akane
提出日時 2020-08-22 13:54:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 191,492 KB
最終ジャッジ日時 2025-01-13 08:11:03
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); i++)
using namespace std;
using ll = long long;


ll mod = 998244353;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
    ios::sync_with_stdio(false);
    ll N,L; cin>>N>>L;
    if(N<=L){
        cout << 1 << endl;
        return 0;
    }
    
    if(N%L==0){
        N = N/L;
    }else{
        N = N/L + 1;
    }
    cerr << N << endl;

    ll ans=2;
    ans = modpow(ans, N, mod);
    cerr << ans << endl;
    cout << ans - 1 << endl;

}
0