제출 #1021587

#제출 시각아이디문제언어결과실행 시간메모리
1021587avighnaCopy and Paste 3 (JOI22_copypaste3)C++17
0 / 100
1 ms456 KiB
#include <bits/stdc++.h> typedef long long ll; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); ll n, a, b, c; std::string s; std::cin >> n >> s >> a >> b >> c; std::vector<ll> dp(n + 1); dp[1] = a; for (ll i = 2; i <= n; ++i) { dp[i] = dp[i - 1] + a; auto update_dp = [&](ll x, ll y) { dp[i] = std::min(dp[i], dp[x] + b + y * c); }; for (ll j = 2; j * j <= i; ++j) { if (i % j == 0) { update_dp(j, i / j); update_dp(i / j, j); } } } std::cout << dp[n] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...