-
Notifications
You must be signed in to change notification settings - Fork 0
/
1249.cpp
37 lines (34 loc) · 819 Bytes
/
1249.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
using namespace std;
int main()
{
int N;
cin>>N;
priority_queue<pair<double, vector<int>>, vector<pair<double, vector<int>>>, greater<pair<double, vector<int>>>> pq;
for(int i=1;i<=N;++i){
for(int j=0;j<=i;++j){
vector<int> v = {j,i};
pq.push(make_pair(double(j)/i, v));
}
}
double lastone = -1;
while(!pq.empty()){
auto t = pq.top();
pq.pop();
if(t.first == lastone){
continue;
}
auto v = t.second;
string res = "";
res = res + to_string(v[0]) + '/' + to_string(v[1]);
cout<<res<<endl;
lastone = t.first;
}
return 0;
}