当前位置:网站首页>-整数求和-
-整数求和-
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;
}
边栏推荐
- typescript45-接口之间的兼容性
- 2. 两数相加
- Fluorescent marker peptides FITC/AMC/FAM/Rhodamine TAMRA/Cy3 / Cy5 / Cy7 - Peptide
- 设计模式——组合模式、享元模式(Integer缓存)(结构型模式)
- 阿里云对象存储oss私有桶生成链接
- 1054 求平均值 (20 分)
- js实现一个 bind 函数
- idea使用@Autowired注解爆红原因及解决方法
- Tributyl-mercaptophosphane "tBuBrettPhos Pd(allyl)" OTf), 1798782-17-8
- 13.< tag-动态规划和回文字串>lt.647. 回文子串 + lt.516.最长回文子序列
猜你喜欢
Install IIS services (Internet Information Services (Internet Information Services, abbreviated IIS, Internet Information Services)
typescript40-class类的保护修饰符
tag单调栈-单调栈预备知识-lt.739. 每日温度
第四次培训
Interface Test Framework Practice (4) | Get Schema Assertion
HarmonyOS应用开发第一次培训
Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
Two ways to simulate multi-user login in Jmeter
Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection
web安全-SSTI模板注入漏洞
随机推荐
typescript47-函数之间的类型兼容性
数据分析 第一篇
The problem that the rosbag tool plotjuggler cannot open rosbag
Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
BIOTIN ALKYNE CAS: 773888-45-2 Price, Supplier
Harmony OS Date ano UI 】 【 】 the basic operation
DFS's complement to pruning
celery工作原理图
web安全-SSTI模板注入漏洞
Exception (abnormal) and Error (error) difference analysis
Build your own web page on the Raspberry Pi (2)
Common lipophilic cell membrane dyes DiO, Dil, DiR, Did spectrograms and experimental procedures
接口和抽象
力扣561. 数组拆分
UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
shell脚本循环语句
2022暑假牛客多校联赛第一场
ss-5.consul服务端+生产者+消费者
web安全-sql注入漏洞
1054 求平均值 (20 分)