結果
問題 | No.1331 Moving Penguin |
ユーザー |
![]() |
提出日時 | 2020-11-04 20:53:36 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 633 bytes |
コンパイル時間 | 2,479 ms |
コンパイル使用メモリ | 163,704 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 13:32:52 |
合計ジャッジ時間 | 32,093 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 40 TLE * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | int N; scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d",&A); | ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") constexpr int mod=1e9+7; int dp[100000]={0}; int main(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); 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(i==N-1) break; if(A!=1){ dp[i+1]+=dp[i]; if(dp[i+1]>=mod) dp[i+1]-=mod; } } std::cout<<dp[N-1]; }