結果
| 問題 |
No.1331 Moving Penguin
|
| コンテスト | |
| ユーザー |
penguinman
|
| 提出日時 | 2020-11-04 20:56:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 578 bytes |
| コンパイル時間 | 2,363 ms |
| コンパイル使用メモリ | 198,832 KB |
| 最終ジャッジ日時 | 2025-01-15 19:48:37 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 37 TLE * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
24 | printf("%ld",dp[N-1]);
| ~~^ ~~~~~~~
| | |
| long int int
| %d
main.cpp:10:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | int N; scanf("%d",&N);
| ~~~~~^~~~~~~~~
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d",&A);
| ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
constexpr int mod=1e9+7;
int dp[100001]={0};
int main(){
std::ios::sync_with_stdio(false);
int N; scanf("%d",&N);
dp[0]=1;
int A;
for(int i=0;i<N;i++){
scanf("%d",&A);
for(int j=i+A;j<N;j+=A){
dp[j]+=dp[i];
if(dp[j]>=mod) dp[j]-=mod;
}
if(A!=1){
dp[i+1]+=dp[i];
if(dp[i+1]>=mod) dp[i+1]-=mod;
}
}
printf("%ld",dp[N-1]);
}
penguinman