当前位置:网站首页>-整数求和-
-整数求和-
2022-08-03 05:10:00 【-JMY-】
题目描述
已知:S= 1+2+3+...+n。显然对于任意一个整数K,当n足够大的时候,S大于K。现给出一个整数K(1<=k<=10000000),要求计算出一个最小的n,使得S>K。
输入
一个整数k
输出
输出满足条件最小的n
样例输入
9
样例输出
4
参考代码:
#include<iostream>
using namespace std;
int main(){
int S=0,n=0,k;
cin>>k;
while(S<=k){
n++;
S+=n;
}
cout<<n;
return 0;
}
边栏推荐
- Flask Web 报错:
- Secondary development of WinForm controls
- ss-4.1-1个eurekaServer+1个providerPayment+1个consumerOrder
- 用scikit-learn学习谱聚类
- Gradle的安装配置
- UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
- idea uses @Autowired annotation to explain the reasons and solutions
- JDBC与连接池
- Build your own web page on raspberry pie (1)
- HarmonyOS应用开发第一次培训
猜你喜欢
2017-06-11 Padavan 完美适配newifi mini【adbyby+SS+KP ...】youku L1 /小米mini

数字孪生园区场景中的坐标知识

MOSN 反向通道详解

typescript39-class类的可见修饰符

web安全-SSTI模板注入漏洞

typescript41-class类的私有修饰符

js实现一个 bind 函数
breed Web刷机升级详细教材修正编译器固件说明_itkeji.top

MCM box model modeling method and source analysis of atmospheric O3

Common lipophilic cell membrane dyes DiO, Dil, DiR, Did spectrograms and experimental procedures
随机推荐
1054 求平均值 (20 分)
Common lipophilic cell membrane dyes DiO, Dil, DiR, Did spectrograms and experimental procedures
信息编码、存储压缩与密码学
Odps temporary query can write SQL, turned out to a named?
typescript41-class类的私有修饰符
Unity2D horizontal board game tutorial 6 - enemy AI and attack animation
1069 微博转发抽奖 (20 分)(C语言)
Djiango第二次培训
celery工作原理图
建造者模式(Builder Pattern)
Lambda表达式案例
Talking about GIS Data (5) - Geographic Coordinate System
web安全-命令执行漏洞
Exception (abnormal) and Error (error) difference analysis
Shell conditional statement judgment
Coordinate knowledge in digital twin campus scenarios
MySql数据库
js实现一个 bind 函数
[Fine talk] Using native js to implement todolist
《录取通知》 观后感