結果

問題 No.1331 Moving Penguin
ユーザー 👑 kmjpkmjp
提出日時 2021-01-09 01:49:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 659 ms / 1,500 ms
コード長 1,278 bytes
コンパイル時間 1,944 ms
コンパイル使用メモリ 195,044 KB
実行使用メモリ 404,864 KB
最終ジャッジ日時 2024-04-25 05:00:00
合計ジャッジ時間 29,293 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
34,432 KB
testcase_01 AC 3 ms
5,504 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 595 ms
404,864 KB
testcase_05 AC 601 ms
404,608 KB
testcase_06 AC 590 ms
404,736 KB
testcase_07 AC 598 ms
404,736 KB
testcase_08 AC 601 ms
404,608 KB
testcase_09 AC 597 ms
404,736 KB
testcase_10 AC 605 ms
404,864 KB
testcase_11 AC 659 ms
404,864 KB
testcase_12 AC 604 ms
404,736 KB
testcase_13 AC 603 ms
404,864 KB
testcase_14 AC 590 ms
404,864 KB
testcase_15 AC 593 ms
404,864 KB
testcase_16 AC 597 ms
404,864 KB
testcase_17 AC 600 ms
404,736 KB
testcase_18 AC 602 ms
404,736 KB
testcase_19 AC 630 ms
404,736 KB
testcase_20 AC 585 ms
404,736 KB
testcase_21 AC 596 ms
404,736 KB
testcase_22 AC 589 ms
404,864 KB
testcase_23 AC 593 ms
404,736 KB
testcase_24 AC 604 ms
404,608 KB
testcase_25 AC 606 ms
404,864 KB
testcase_26 AC 599 ms
404,864 KB
testcase_27 AC 612 ms
404,736 KB
testcase_28 AC 595 ms
404,736 KB
testcase_29 AC 599 ms
404,736 KB
testcase_30 AC 264 ms
138,368 KB
testcase_31 AC 460 ms
230,912 KB
testcase_32 AC 229 ms
122,752 KB
testcase_33 AC 338 ms
181,504 KB
testcase_34 AC 400 ms
273,280 KB
testcase_35 AC 591 ms
404,736 KB
testcase_36 AC 597 ms
404,608 KB
testcase_37 AC 601 ms
404,608 KB
testcase_38 AC 209 ms
144,896 KB
testcase_39 AC 592 ms
391,552 KB
testcase_40 AC 308 ms
204,032 KB
testcase_41 AC 596 ms
404,608 KB
testcase_42 AC 592 ms
404,608 KB
testcase_43 AC 607 ms
404,864 KB
testcase_44 AC 617 ms
404,736 KB
testcase_45 AC 578 ms
404,736 KB
testcase_46 AC 624 ms
404,864 KB
testcase_47 AC 596 ms
404,736 KB
testcase_48 AC 595 ms
404,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
int A[101010];
ll dp[101010][510];
ll S[101010];
const ll mo=1000000007;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	S[0]=1;
	for(i=1;i<=N;i++) {
		cin>>x;
		
		S[i]+=S[i-1];
		for(j=1;j<=500;j++) {
			S[i]+=dp[i][j];
			(dp[i+j][j]+=dp[i][j])%=mo;
		}
		S[i]%=mo;
		
		
		if(i==N) cout<<S[i]<<endl;
		
		if(x==1) {
			(dp[i+2][1]+=S[i])%=mo;
		}
		else if(x<=500) {
			(dp[i+x][x]+=S[i])%=mo;
		}
		else {
			for(j=i+x;j<=N;j+=x) S[j]+=S[i];
		}
		
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0