A. Vasya and Chocolate
https://codeforces.com/problemset/problem/1065/A
a개를 사면 b개가 꽁짜!
가격이 c원이고, s원을 가지고 있을 때, 최대로 살 수 있는 초콜릿의 개수를 구하면 된다.
처음 더해주는 것은 정확히 a개씩 몇개 살 수 있는지 구하고, 증정품까지 더해서 살 수 있는 최대 개수
다음으로 더해주는 것은 증정품 필요 없이 그냥 남은거 살 수 있는 만큼 사는 개수
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <bits/stdc++.h> using namespace std; int t; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> t; while (t--) { long long s, a, b, c, ans = 0; cin >> s >> a >> b >> c; ans += (s / c) / a * (a + b); ans += (s / c) % a; cout << ans << '\n'; } return 0; } | cs |
'Competition > codeforces' 카테고리의 다른 글
Codeforces Round #527 (Div. 3) B. Teams Forming (0) | 2019.03.30 |
---|---|
Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) A. Make a triangle! (0) | 2019.03.30 |
Educational Codeforces Round 53 (Rated for Div. 2) A. Diverse Substring (0) | 2019.03.30 |
Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) A. The King's Race (0) | 2019.03.30 |
Codeforces Round #521 (Div. 3) A. Frog Jumping (0) | 2019.03.30 |