結果

問題 No.2857 Div Array
ユーザー yuusaanyuusaan
提出日時 2024-08-25 15:36:05
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 7,330 bytes
コンパイル時間 5,741 ms
コンパイル使用メモリ 322,804 KB
実行使用メモリ 13,752 KB
最終ジャッジ日時 2024-08-25 15:36:15
合計ジャッジ時間 9,286 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <tuple>
#include <map>
#include<set>
#include<queue>
#include<stack>
#include <unordered_set>
#include<thread>
#include<bits/stdc++.h>
#include <atcoder/all>
#include <cstdio>
// #pragma GCC target("avx")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
//if(a < 0 || h <= a || b < 0 || w <= b)return;
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using mint = modint998244353;
//using mint = modint1000000007;
//using VL = vector<ll>;
template<typename T> using pq = priority_queue<T>;//?()
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;//?()
template<typename T> using vector2 = vector<vector<T>>;
template<typename T> using vector3 = vector<vector<vector<T>>>;
template<typename T> using vector4 = vector<vector<vector<vector<T>>>>;
template<typename T> using vector5 = vector<vector<vector<vector<vector<T>>>>>;
template<typename T> using vector6 = vector<vector<vector<vector<vector<vector<T>>>>>>;
template<typename T> using pairs = pair<T,T>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define rep1(i,n) for(int i = 1;i <= int(n);i++)
#define repm(i, m, n) for (int i = (m); (i) < int(n);(i)++)
#define repmr(i, m, n) for (int i = (m) - 1; (i) >= int(n);(i)--)
#define rep0(i,n) for(int i = n - 1;i >= 0;i--)
#define rep01(i,n) for(int i = n;i >= 1;i--)
// NKN < 2^64, K <= 64
uint64_t kth_root(uint64_t N, uint64_t K) {
assert(K >= 1);
if (N <= 1 || K == 1) return N;
if (K >= 64) return 1;
if (N == uint64_t(-1)) --N;
auto mul = [&](uint64_t x, uint64_t y) -> uint64_t {
if (x < UINT_MAX && y < UINT_MAX) return x * y;
if (x == uint64_t(-1) || y == uint64_t(-1)) return uint64_t(-1);
return (x <= uint64_t(-1) / y ? x * y : uint64_t(-1));
};
auto power = [&](uint64_t x, uint64_t k) -> uint64_t {
if (k == 0) return 1ULL;
uint64_t res = 1ULL;
while (k) {
if (k & 1) res = mul(res, x);
x = mul(x, x);
k >>= 1;
}
return res;
};
uint64_t res;
if (K == 2) res = sqrtl(N) - 1;
else if (K == 3) res = cbrt(N) - 1;
else res = pow(N, nextafter(1 / double(K), 0));
while (power(res + 1, K) <= N) ++res;
return res;
}
//
ll GCD(ll a,ll b){
if(b == 0)return a;
return GCD(b, a % b);
}
//(ax + by = GCD(a,b))x,y
pair<long long, long long> extgcd(long long a, long long b) {
if (b == 0) return make_pair(1, 0);
long long x, y;
tie(y, x) = extgcd(b, a % b);
y -= a / b * x;
return make_pair(x, y);
}
struct UnionFind {
vector<int> par; // par[i]:i () par[3] = 2 : 32
UnionFind(int N) : par(N) { //
for(int i = 0; i < N; i++) par[i] = i;
}
int root(int x) { // xroot(x) = {x}
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) { // xy
int rx = root(x); //xrx
int ry = root(y); //yry
if (rx == ry) return; //xy(=)
par[rx] = ry; //xy(=)xrxyry
}
bool same(int x, int y) { // 2x, ytrue
int rx = root(x);
int ry = root(y);
return rx == ry;
}
};
ll n;
struct UnionFind2 {
vector2<int> par; // par[i]:i () par[3] = 2 : 32
UnionFind2(int N) : par(N,vector<int>(N)) { //
for(int i = 0; i < N; i++)for(int j = 0;j < N;j++) par[i][j] = i * N + j;
}
int root(int y,int x) { // xroot(x) = {x}
if (par[y][x] == y * n + x) return y * n +x;
return par[y][x] = root(par[y][x] / n,par[y][x] % n);
}
void unite(int y0, int x0,int y1,int x1) { // xy
int rx = root(y0,x0); //xrx
int ry = root(y1,x1); //yry
if (rx == ry) return; //xy(=)
par[rx / n][rx % n] = ry; //xy(=)xrxyry
}
bool same(int y0, int x0,int y1,int x1) { // 2x, ytrue
int rx = root(y0,x0);
int ry = root(y1,x1);
return rx == ry;
}
};
//
vector<ll> Ccomp(vector<ll> a){
vector<ll> b = a;
sort(b.begin(),b.end());
b.erase(unique(b.begin(),b.end()),b.end());//
vector<ll> rtn;
rep(j,a.size()){
ll pb = lower_bound(b.begin(),b.end(),a[j]) - b.begin();
rtn.push_back(pb);
}
return rtn;
}
/// ////////////////////////////////////////////
using F = ll;
using S = ll;
string s;
ll modPow(ll a, ll n, ll mod) { if(mod==1) return 0;ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1;
    } return ret; }
void cincout(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout<< fixed << setprecision(15);
}
//seg,seg-----
S op(S a,S b){return max(a,b);}//()
S e(){return -1;}//()
ll v;
//bool f(ll a){return v > a;}//
//S mapping (F a,S b){return a + b;}//
F composition (F a,F b){return a + b;}//
F id(){return 0;}//
vector<int> Op(vector<int> a,vector<int> b){a.insert(a.end(),b.begin(),b.end()); return a;}
vector<int> E(){return vector<int> (0);}
//seg
string abc = "abcdefghijklmnopqrstuvwxyz";
//string abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ll mod = 998244353;
ll INF =ll(2e18);
int main() {
cincout();
ll m,k;
cin >> n >> m >> k;
vector<mint> a(m+1,0);
for(int j = 1;j <= m;j++){
a[m/j]++;
}
auto dptim = [&](vector<mint> a,vector<mint> b){
vector<mint> asum(m+1,0);
rep1(j,m){
asum[j] = asum[j-1] + a[j];
}
vector<mint> rt(m+1,0);
rep1(j,m){
rt[j] = (asum[min(m,j + k)] - asum[max(0LL,j-k-1)]) * b[j];
}
return rt;
};
vector<mint> ndp(m+1,0);
vector<mint> ansdp(m+1,0);
rep1(j,m)ansdp[j] = a[j];
rep1(j,m)ndp[j] = a[j];
ll t = 0;
bool c = 0;
for(int j = 2;j <= n;j++){
ansdp = dptim(ansdp,ndp);
}
mint ans = 0;
rep1(j,m)ans += ansdp[j];
cout << ans.val() << endl;
// for(int j = 1;j <= n;j++){
// for(int i = 1;i <= m;i++){
// cout << dp[j][i].val() << " ";
// }
// cout << endl;
// }
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0