当前位置:网站首页>-整数求和-
-整数求和-
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;
}
边栏推荐
- Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection
- vim命令
- Benchmark 第一篇 了解Benchmark
- Build your own web page on the Raspberry Pi (2)
- typescript40-class类的保护修饰符
- [Fine talk] Using native js to implement todolist
- ss-1.curl (cloud-provider-payment8001)
- Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
- Fluorescent marker peptides FITC/AMC/FAM/Rhodamine TAMRA/Cy3 / Cy5 / Cy7 - Peptide
- 阿里云对象存储oss私有桶生成链接
猜你喜欢
随机推荐
Interface test Mock combat (2) | Combined with jq to complete batch manual Mock
typescript40-class类的保护修饰符
DFS's complement to pruning
高效率科研神器——小软件、大能量
Interface Test Framework Practice (4) | Get Schema Assertion
接口和抽象
ss-4.2 多个eureka集群案例
Installation of Apache DolphinScheduler version 2.0.5 distributed cluster
传说中可“免费白拿”的无线路由器 - 斐讯 K2 最简单刷 breed 与第三方固件教程
Super handy drawing tool is recommended
web安全-sql注入漏洞
Shell conditional statement judgment
Online password generator tool recommendation
Odps temporary query can write SQL, turned out to a named?
[Harmony OS] [ARK UI] ETS context basic operations
PotPlayer实现上班摸鱼电视自由
初步认识ZK
Pr第四次培训笔记
Djiango第三次培训
数字孪生园区场景中的坐标知识









