Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // OK 1011 Timus https://acm.timus.ru/problem.aspx?space=1&num=1011
- # include <iostream>
- # include <cmath>
- int main() {
- double p, q;
- std::ios_base::sync_with_stdio(false);
- std::cin >> p >> q;
- size_t p_int = p * 1000;
- if (p_int % 10 == 9) {
- p_int++;
- }
- size_t q_int = q * 1000;
- if (q_int % 10 == 9) {
- q_int++;
- }
- size_t i = 0;
- while (++i > 0) {
- for (auto j = std::max(static_cast<int32_t>(p * i / 1000) - 2, 0); j <= i; j++) {
- if (j * 100'000 > i * p_int && j * 100'000 < i * q_int) {
- std::cout << i << '\n';
- return 0;
- } else if (j * 100'000 > i * q_int) {
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement