結果
| 問題 | No.2060 AND Sequence |
| コンテスト | |
| ユーザー |
👑 Nachia
|
| 提出日時 | 2024-04-22 22:50:09 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 671 bytes |
| 記録 | |
| コンパイル時間 | 435 ms |
| コンパイル使用メモリ | 95,196 KB |
| 実行使用メモリ | 9,968 KB |
| 最終ジャッジ日時 | 2026-07-04 15:22:29 |
| 合計ジャッジ時間 | 2,008 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <atcoder/modint>
using namespace std;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
using modint = atcoder::static_modint<998244353>;
modint f(u64 N, u64 M){
if(M == 0) return 1;
u64 d = 1;
u64 logd = 0;
while((d<<1) <= M){ d<<=1; logd++; }
modint ans = 0;
ans += modint(N+1).pow(logd);
ans += f(N, M-d) * modint(N);
return ans;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, M; cin >> N >> M;
auto ans = f(N, M);
cout << ans.val() << '\n';
return 0;
}
Nachia