結果
| 問題 | No.1353 Limited Sequence |
| コンテスト | |
| ユーザー |
PCTprobability
|
| 提出日時 | 2021-01-14 19:06:49 |
| 言語 | C++17(clang) (clang++ 22.1.2 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,531 bytes |
| 記録 | |
| コンパイル時間 | 1,550 ms |
| コンパイル使用メモリ | 176,536 KB |
| 実行使用メモリ | 35,072 KB |
| 最終ジャッジ日時 | 2026-05-18 11:36:46 |
| 合計ジャッジ時間 | 3,670 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 6 WA * 40 |
コンパイルメッセージ
main.cpp:30:14: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
30 | ll dp[r+1][n+1];
| ^~~
main.cpp:30:14: note: read of non-const variable 'n' is not allowed in a constant expression
main.cpp:23:6: note: declared here
23 | ll n,l,r;
| ^
main.cpp:30:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
30 | ll dp[r+1][n+1];
| ^~~
main.cpp:30:9: note: read of non-const variable 'r' is not allowed in a constant expression
main.cpp:23:10: note: declared here
23 | ll n,l,r;
| ^
main.cpp:31:10: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
31 | ll sum[r+1];
| ^~~
main.cpp:31:10: note: read of non-const variable 'r' is not allowed in a constant expression
main.cpp:23:10: note: declared here
23 | ll n,l,r;
| ^
3 warnings generated.
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(s) (s).begin(),(s).end()
#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
const ll mod = 998244353;
//const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }
int main() {
/* mod は 1e9+7 */
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout<< fixed << setprecision(10);
ll n,l,r;
cin>>n>>l>>r;
vector<ll> a(n);
// vcin(a);
for(int i=0;i<n;i++){
a[i]=1;
}
ll dp[r+1][n+1];
ll sum[r+1];
for(int i=0;i<=r;i++){
for(int j=0;j<=n;j++){
dp[i][j]=0;
}
}
for(int i=0;i<=r;i++){
sum[i]=0;
}
dp[0][0]=1;
sum[0]=1;
for(int i=0;i<=r;i++){
for(int j=1;j<=n;j++){
ll t=dp[i][j];
for(int k=1;j*k<=i&&k<=a[j-1];k++){
t+=sum[i-k*j]-dp[i-k*j][j];
t%=mod;
t+=mod;
t%=mod;
}
t%=mod;
dp[i][j]=t;
sum[i]+=t;
sum[i]%=mod;
}
}
ll ans=0;
for(int i=l;i<=r;i++){
ans+=sum[i];
ans%=mod;
}
cout<<ans<<endl;
}
PCTprobability