結果

問題 No.1581 Multiple Sequence
ユーザー 37zigen37zigen
提出日時 2021-07-03 17:52:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 65,620 KB
実行使用メモリ 19,888 KB
最終ジャッジ日時 2023-09-12 22:31:55
合計ジャッジ時間 2,578 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 70 ms
17,116 KB
testcase_03 AC 78 ms
18,076 KB
testcase_04 AC 19 ms
8,168 KB
testcase_05 AC 81 ms
18,632 KB
testcase_06 AC 33 ms
10,792 KB
testcase_07 AC 18 ms
7,804 KB
testcase_08 AC 24 ms
9,064 KB
testcase_09 AC 74 ms
17,292 KB
testcase_10 AC 44 ms
13,132 KB
testcase_11 AC 10 ms
5,628 KB
testcase_12 AC 27 ms
9,724 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 81 ms
18,276 KB
testcase_15 AC 50 ms
14,504 KB
testcase_16 AC 12 ms
6,224 KB
testcase_17 AC 98 ms
19,704 KB
testcase_18 AC 8 ms
5,256 KB
testcase_19 AC 74 ms
16,584 KB
testcase_20 AC 75 ms
16,984 KB
testcase_21 AC 74 ms
18,028 KB
testcase_22 AC 37 ms
11,968 KB
testcase_23 AC 98 ms
19,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<list>
typedef long long ll;

using namespace std;
const ll p = (ll) 1e9+7;

int main() {
		ll M;
		cin >> M;
		
		vector<vector<ll>> ds(M+1,vector<ll>());
		for (int d=2;d<=M;++d) {
				for (int i=1;i*d<=M;++i) {
						ds[i*d].push_back(d);
				}
		}
		
		vector<ll> dp(M+1);
		vector<ll> s(M+1);
		s[0]=1;
		dp[0]=1;
		for (int i=1;i<=M;++i) {
				for (ll d : ds[i]) {
						dp[i]+=s[i/d-1];
						dp[i]%=p;
				}
				s[i]=(s[i-1]+dp[i])%p;
		}
		cout << s[M] << endl;
}
0