某君从某年开始每年都举办一次生日party,并且每次都要吹熄与年龄相同根数的蜡烛。
现在算起来,他一共吹熄了236根蜡烛。
请问,他从多少岁开始过生日party的?
请填写他开始过生日party的年龄数。
注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。
26
#include <iostream>
using namespace std;
#define MAX 110
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main() {
int sum;
for(int st = 0; st <= MAX; st++)
{
for(int end = MAX; end >= 1; end--)
{
if(st < end)
{
sum = (st + end)*(end - st + 1);
sum /= 2;
if(sum == 236)
{
cout<<"st= "<<st<<" ";
cout<<"end= "<<end<<" ";
cout<<"sum = "<<sum<<endl;
cout<<st<<endl;
return 0;
}
}
}
}
return 0;
}