結果
問題 |
No.1331 Moving Penguin
|
ユーザー |
![]() |
提出日時 | 2020-11-03 18:12:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,287 bytes |
コンパイル時間 | 748 ms |
コンパイル使用メモリ | 100,024 KB |
最終ジャッジ日時 | 2025-01-15 19:25:25 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 40 TLE * 9 |
ソースコード
#include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <deque> // deque #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using std::cin; using std::cout; #define endl "\n" using std::vector; 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; cin>>N; dp[0]=1; for(int i=0;i<N;i++){ int A; cin>>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&&A!=1){ dp[i+1]+=dp[i]; if(dp[i+1]>=mod) dp[i+1]-=mod; } } cout<<dp[N-1]<<endl; }