当前位置:网站首页>As a result, fill in the birthday candles
As a result, fill in the birthday candles
2022-07-28 07:01:00 【White mouse zero】
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 did he start celebrate sb 's birthday party Of ?
Please fill in his birthday party The age of .
answer
26
The problem solving process
It is very routine to use the formula of arithmetic sequence +for Problems that can be solved by circulation .
Attach code
#include<iostream>
using namespace std;
int main()
{
void find();
find();
return 0;
}
void find()
{
int sum=0;
for(int i=1;i<=100;i++)
{
for(int j=100;j>i;j--)
{
sum=(i+j)*(j-i+1)/2;
if(sum<236)
break;
if(sum==236)
{
cout<<i<<endl;
return;
}
}
}
}
边栏推荐
- LNMP搭建过程详解
- 什么是线性表?
- [learning notes] process creation
- Software testing (concept)
- MOOC翁恺 C语言 第三周:判断与循环:2.循环
- 小甲鱼C(第五章循环控制结构程序567)break和continue语句
- MOOC翁恺C语言第八周:指针与字符串:1.指针2.字符类型3.字符串4.字符串计算
- DNS域名解析服务
- Technology sharing | detailed explanation of actual combat interface test request methods get, post
- Custom component -- communication between parent and child components
猜你喜欢
随机推荐
QT uses MSVC compiler to output Chinese garbled code
Applets: lifecycle
Custom component -- data listener
Technology sharing | do you know the functions of the server interface automated testing and requests library?
Servlet
Shell script - regular expression
VMware Workstation 配置net模式
[learning notes] thread creation
Network - network layer
MySQL master-slave
Esxi community network card driver updated again
Hdu-5805-nanoape loves sequence (thinking questions)
HDU-5783 Divide the Sequence(贪心水题)
Use powercli to create a custom esxi ISO image
MOOC翁恺C语言第五周:1.循环控制2.多重循环3.循环应用
Hdu-1159-commonsubsequence (LCS longest common subsequence)
什么是线性表?
Custom components -- styles
Clock tree analysis example
MySQL常用命令









