Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cmath>
- #include <algorithm>
- #include <queue>
- #include <map>
- #include <set>
- #include <bitset>
- using namespace std;
- typedef long long ll;
- typedef double d;
- struct ans{
- d x;
- d m, n;
- };
- bool operator <(ans a, ans b){
- return a.x < b.x;
- }
- int gcd(int v, int u){
- while(v > 0 && u > 0){
- if(v >= u){
- v %= u;
- }
- else
- u %= v;
- }
- return v + u;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int n;
- int p, q;
- double a, b;
- cin >> n >> p >> q;
- a = (d)1 / p;
- b = (d)1 / q;
- vector<ans> res;
- for(d i = 1; i <= n; i += 1){
- for(d j = 1; j <= i; j += 1){
- if(gcd((int)j, (int)i) > 1){
- continue;
- }
- d v = j / i;
- if(v > a && v < b){
- res.push_back({v, j, i});
- }
- }
- }
- sort(res.begin(), res.end());
- for(int i = 0; i < res.size(); ++i){
- cout << (int) res[i].m << "/" << (int) res[i].n << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement