当前位置:网站首页>Blue Bridge Cup Birthday candles (violence)

Blue Bridge Cup Birthday candles (violence)

2022-07-07 07:17:00 Woodenman Du

Question:

Title Description

This question is to fill in the blanks , Just calculate the result , Use the output statement in the code to output the filled results .

From a certain year on, you hold a birthday every year party, And blow out the same number of candles with the same age every time .

Now count , He blew it out altogether 236 A candle .

Excuse me, , How old was his birthday party Of ?

Please output his birthday  party The age of .

Operation limit

  • Maximum operation time :1s
  • Maximum running memory : 128M

Result:26

Code:

#include <iostream>
using namespace std;
int main()
{
  // There should be nothing to explain , Just try it with direct violence 
  for(int i = 1; i < 100; i++){
    int sum = 0;    // initialization 
    for(int j = i; j < 100; j++){
      sum += j;
      if(sum == 236) { cout <<i; return 0; }
      if(sum > 236) break;    // More than the , direct break
    }
  }
  return 0;
}
// In fact, the purpose of writing notes is to make up the number of words 

Statement : For the purpose of sorting out personal questions , In case of infringement , Please contact to delete ~

原网站

版权声明
本文为[Woodenman Du]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130713287128.html