当前位置:网站首页>-整数求和-
-整数求和-
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;
}
边栏推荐
- [Fine talk] Using native js to implement todolist
- Flask的简单介绍及使用方法简介
- Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection
- typescript45-接口之间的兼容性
- Secondary development of WinForm controls
- Detailed explanation of MOSN reverse channel
- web安全-命令执行漏洞
- Where is the value of testers
- Presto installation and deployment tutorial
- Install IIS services (Internet Information Services (Internet Information Services, abbreviated IIS, Internet Information Services)
猜你喜欢

typescript45-接口之间的兼容性

Pr第二次培训笔记

第三次HarmonyOS培训

Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection

How to prepare for the test interface test data

13.
lt.647. Palindromic substring + lt.516. Longest palindrome subsequence 
Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface

ModelArts第二次培训

web安全-SSTI模板注入漏洞

【Harmony OS】【ARK UI】ets use startAbility or startAbilityForResult to invoke Ability
随机推荐
celery工作原理图
阿里云对象存储oss私有桶生成链接
High availability, two locations and three centers
typescript44-对象之间的类兼容器
在树莓派上搭建属于自己的网页(2)
typescript46-函数之间的类型兼容性
第四次培训
HarmonyOS应用开发第一次培训
【Harmony OS】【ARK UI】ets use startAbility or startAbilityForResult to invoke Ability
1079 延迟的回文数 (20 分)
typescript42-readonly修饰符
4.如何避免缓存穿透、缓存击穿、缓存雪崩
Gradle的安装配置
2017-06-11 Padavan 完美适配newifi mini【adbyby+SS+KP ...】youku L1 /小米mini
13.< tag-动态规划和回文字串>lt.647. 回文子串 + lt.516.最长回文子序列
VSO Downloader Ultimate 5.0.1.45 中文多语免费版 在线视频下载工具
Newifi路由器第三方固件玩机教程,这个路由比你想的更强大以及智能_Newifi y1刷机_smzdm
建立树形结构
业务表解析-余额系统
用户密码验证