找规律
/*
A triangular number is the number of dots that can be packed in an equilateral triangle with n dots on a side. Here are a few example triangles, with their corresponding triangular numbers:
You can easily see that a triangular number is the additive equivalent of a factorial:
Your team is to write a program that will, given an integer value, determine if it is a triangular number. If the given value is a triangular number, determine the number of dots on a side.
Example:If k is 10, your program will report that it is a triangular number with 4 dots on a side, since 10 = 4 + 3 + 2 + 1. If kis 11, your program will report that it is not a triangular number.
Input
Output
*/
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int num;
int n;
while(cin>>num)
{
n=(int)pow(2.0*num,0.5);
if((n*(1+n))/2==num)
cout<<n<<endl;
else
cout<<"bad"<<endl;
}
return 0;
}