USACO 2.1.2 – Ordered Fractions

#include <cstdio>

using namespace std;
int n;
void gen(pair<int, int> a, pair<int, int> b){
	pair<int, int> mid = make_pair(a.first+b.first, a.second + b.second);
	gen(a, mid);
	printf("%d/%d\n", mid.first, mid.second);
	gen(mid, b);
int main() {
	freopen("", "r", stdin), freopen("frac1.out", "w", stdout);
	scanf("%d", &n);
	gen(make_pair(0, 1), make_pair(1, 1));
	return 0;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: