結果

問題 No.1532 Different Products
ユーザー SSRSSSRS
提出日時 2021-06-04 20:22:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,266 ms / 4,000 ms
コード長 1,133 bytes
コンパイル時間 1,819 ms
コンパイル使用メモリ 177,760 KB
実行使用メモリ 323,640 KB
最終ジャッジ日時 2023-11-23 11:08:31
合計ジャッジ時間 80,340 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 365 ms
55,244 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 6 ms
6,676 KB
testcase_08 AC 19 ms
6,676 KB
testcase_09 AC 204 ms
32,080 KB
testcase_10 AC 510 ms
75,088 KB
testcase_11 AC 417 ms
61,776 KB
testcase_12 AC 1,138 ms
163,512 KB
testcase_13 AC 834 ms
118,200 KB
testcase_14 AC 1,850 ms
266,424 KB
testcase_15 AC 228 ms
35,384 KB
testcase_16 AC 395 ms
61,772 KB
testcase_17 AC 494 ms
71,760 KB
testcase_18 AC 458 ms
66,744 KB
testcase_19 AC 1,095 ms
157,496 KB
testcase_20 AC 1,894 ms
269,624 KB
testcase_21 AC 591 ms
88,140 KB
testcase_22 AC 773 ms
110,520 KB
testcase_23 AC 601 ms
85,432 KB
testcase_24 AC 1,745 ms
248,888 KB
testcase_25 AC 956 ms
139,344 KB
testcase_26 AC 138 ms
22,860 KB
testcase_27 AC 789 ms
119,120 KB
testcase_28 AC 633 ms
94,544 KB
testcase_29 AC 461 ms
72,396 KB
testcase_30 AC 1,061 ms
157,776 KB
testcase_31 AC 1,094 ms
161,232 KB
testcase_32 AC 1,278 ms
186,832 KB
testcase_33 AC 970 ms
144,720 KB
testcase_34 AC 1,608 ms
233,272 KB
testcase_35 AC 1,271 ms
185,936 KB
testcase_36 AC 1,561 ms
226,872 KB
testcase_37 AC 225 ms
38,092 KB
testcase_38 AC 1,676 ms
242,360 KB
testcase_39 AC 1,488 ms
216,120 KB
testcase_40 AC 1,523 ms
220,728 KB
testcase_41 AC 2,200 ms
313,784 KB
testcase_42 AC 1,941 ms
278,840 KB
testcase_43 AC 2,039 ms
291,640 KB
testcase_44 AC 2,223 ms
318,136 KB
testcase_45 AC 2,232 ms
319,032 KB
testcase_46 AC 2,158 ms
309,432 KB
testcase_47 AC 2,250 ms
322,360 KB
testcase_48 AC 2,231 ms
318,520 KB
testcase_49 AC 2,235 ms
320,312 KB
testcase_50 AC 2,250 ms
318,008 KB
testcase_51 AC 2,251 ms
321,336 KB
testcase_52 AC 2,202 ms
315,192 KB
testcase_53 AC 2,264 ms
322,616 KB
testcase_54 AC 2,201 ms
315,320 KB
testcase_55 AC 2,235 ms
319,800 KB
testcase_56 AC 2,213 ms
309,048 KB
testcase_57 AC 2,181 ms
311,480 KB
testcase_58 AC 2,218 ms
316,984 KB
testcase_59 AC 2,098 ms
299,448 KB
testcase_60 AC 2,266 ms
323,640 KB
testcase_61 AC 2 ms
6,676 KB
testcase_62 AC 2 ms
6,676 KB
testcase_63 AC 2,239 ms
319,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, pair<long long, long long>>> quotient_ranges(long long N){
	vector<pair<long long, pair<long long, long long>>> ans;
	for (long long i = 1; i * i <= N; i++){
		ans.push_back(make_pair(N / i, make_pair(i, i)));
	}
	for (long long i = N / ((long long) sqrt(N) + 1); i >= 1; i--){
		ans.push_back(make_pair(i, make_pair(N / (i + 1) + 1, N / i)));
	}
	return ans;
}
int main(){
  int N;
  long long K;
  cin >> N >> K;
  vector<pair<long long, pair<long long, long long>>> R = quotient_ranges(K);
  reverse(R.begin(), R.end());
  int M = R.size();
  vector<vector<long long>> dp(N + 1, vector<long long>(M, 0));
  dp[0][M - 1] = 1;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      dp[i + 1][j] += dp[i][j];
      long long x = R[j].first / (i + 1);
      if (x > 0){
        int p = lower_bound(R.begin(), R.end(), make_pair(x, make_pair((long long) -1, (long long) -1))) - R.begin();
        dp[i + 1][p] += dp[i][j];
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < M; i++){
    ans += dp[N][i];
  }
  ans--;
  cout << ans << endl;
}
0