結果
| 問題 | No.1581 Multiple Sequence | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-07-03 17:53:18 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 119 ms / 2,000 ms | 
| コード長 | 503 bytes | 
| コンパイル時間 | 506 ms | 
| コンパイル使用メモリ | 64,228 KB | 
| 実行使用メモリ | 20,096 KB | 
| 最終ジャッジ日時 | 2024-06-30 10:04:46 | 
| 合計ジャッジ時間 | 2,574 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:40: 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’} [-Wnarrowing]
   13 |                 vector<vector<ll>> ds{M+1};
      |                                       ~^~
            
            ソースコード
#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;
}
            
            
            
        