生日蜡烛
某君从某年开始每年都举办一次生日party,并且每次都要吹熄与年龄相同根数的蜡烛。
现在算起来,他一共吹熄了236根蜡烛。
请问,他从多少岁开始过生日party的?
请填写他开始过生日party的年龄数。
注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。
public class S2016JavaA_2 {
public static void main(String[] args) {
Map<Integer,Integer> hash=new HashMap<Integer,Integer>();
for(int i=1;;i++){
int temp=(1+i)*i/2;
if(hash.containsKey(temp-236)){
System.out.println(hash.get(temp-236)+1);
break;
}
hash.put(temp, i);
}
}
}