結果
問題 |
No.1532 Different Products
|
ユーザー |
|
提出日時 | 2021-05-02 04:50:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,614 bytes |
コンパイル時間 | 1,210 ms |
コンパイル使用メモリ | 126,636 KB |
最終ジャッジ日時 | 2025-01-21 05:39:49 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 11 WA * 51 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <map> #include <set> #include <queue> #include <algorithm> #include <cmath> #include <iomanip> #include <random> #include <stdio.h> #include <fstream> //#include <atcoder/all> #include <functional> using namespace std; //using namespace atcoder; using ll = long long; using pll = pair<ll,ll>; //using mint = modint998244353; #define all(i) (i).begin(),(i).end() #define pb push_back #define INF 100000000000000000 #define rep(i,n) for (int i=0;i<n;i++) #define rep2(l,r) for (int i=l;i<r;i++) bool chmin(ll &x,ll a){ if (x > a){ x = a; return 1; } else{ return 0; } } bool chmax(ll &x,ll a){ if (x < a){ x = a; return 1; } else{ return 0; } } int dp[210][10001]; void calc(int N){ dp[N+1][1] = 1; for (int i=N;i>=1;i--){ for (int prod=1;prod<10001;prod++){ dp[i][prod] += dp[i+1][prod]; if (prod*i < 10001){ dp[i][prod*i] += dp[i+1][prod]; } } } for (int i=0;i<N+2;i++){ for (int j=1;j<10001;j++){ dp[i][j] += dp[i][j-1]; } } } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int N,K; cin>>N>>K; calc(N); queue<pair<int,int>> A; A.push(make_pair(1,1)); ll res=-1; while (!A.empty()){ auto [val,L] = A.front(); A.pop(); res += 1; for (int i=L;i<=N;i++){ if (val*i<=K){ if (val*i>=100000){ res += dp[i+1][K/(val*i)]; } else{ A.push({val*i,i+1}); } } else{ break; } } } cout<<res%998244353<<endl; }