
tri2
By: a guest on
Aug 22nd, 2012 | syntax:
C++ | size: 0.34 KB | hits: 14 | expires: Never
#include<fstream>
#include<cmath>
using namespace std;
int main()
{
int x,n;
ifstream fin("tri.in");
ofstream tri("tri.out");
ofstream rest("rest.out");
while(fin>>x)
{
x*=2;
n=int(sqrt(double(x)));
if(n*(n+1)==x) tri<<x/2<<" ";
else rest<<x/2<<" ";
}
fin.close();
tri.close();
rest.close();
return 0;
}