Дроби-1

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
724 B
0
Indexable
Never
#include <iostream>
using std::cout; 
using std::cin; 
using std::endl;

bool nat(int i, int j);

int main()
{
    float x;
    int n;

    cin >> x;
    cin >> n;

    int count = 0;

    for (int i = 2; i < n + 1; i++) {
        for (int j = 1; j < i; j++) {
            if (static_cast<float>(j) / i <= x) {
                if (nat(j, i)) {
                    count++;
                }
            }
            else {
                j = i;
            }
        }
    }

    cout << count;
}


bool nat(int i, int j) {
    if (i % j == 0 && j != 1) return false;
    for (int x = 2; x < j + 2; x++) {
        if (i % x == 0 && j % x == 0) return false;
    }
    return true;
}
Leave a Comment