Saturday, June 6, 2015

UVa 138 - Street Numbers

// UVa 138 - Street Numbers

#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

#define ttype unsigned long long

int main() {
	ttype n = 1;
	for (int c = 1; c <= 10; c++) {
		ttype sq, x;
		do {
			n++;
			sq = n * (n + 1) / 2;
			x = (ttype) (sqrt(sq));
		} while (x * x != sq);
		printf("%10llu%10llu\n", x, n);
	}
	return 0;
}

No comments:

Post a Comment