結果

問題 No.1581 Multiple Sequence
ユーザー 37zigen37zigen
提出日時 2021-07-03 17:53:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 455 ms
コンパイル使用メモリ 63,944 KB
実行使用メモリ 19,888 KB
最終ジャッジ日時 2023-09-12 22:33:24
合計ジャッジ時間 2,559 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 65 ms
17,036 KB
testcase_03 AC 72 ms
18,204 KB
testcase_04 AC 19 ms
8,060 KB
testcase_05 AC 72 ms
18,560 KB
testcase_06 AC 31 ms
10,696 KB
testcase_07 AC 19 ms
7,912 KB
testcase_08 AC 24 ms
9,060 KB
testcase_09 AC 69 ms
17,344 KB
testcase_10 AC 44 ms
13,076 KB
testcase_11 AC 10 ms
5,676 KB
testcase_12 AC 26 ms
9,636 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 73 ms
18,036 KB
testcase_15 AC 50 ms
14,336 KB
testcase_16 AC 12 ms
6,204 KB
testcase_17 AC 81 ms
19,608 KB
testcase_18 AC 9 ms
5,176 KB
testcase_19 AC 64 ms
16,500 KB
testcase_20 AC 63 ms
16,976 KB
testcase_21 AC 75 ms
18,352 KB
testcase_22 AC 38 ms
12,020 KB
testcase_23 AC 83 ms
19,888 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:26: warning: narrowing conversion of ‘(M + 1)’ from ‘ll’ {aka ‘long long int’} to ‘std::vector<std::vector<long long int> >::size_type’ {aka ‘long unsigned int’} inside { } [-Wnarrowing]
   vector<vector<ll>> ds{M+1};
                         ~^~

ソースコード

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};
		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