CF47A Triangular numbers
题意翻译
给定一个数n,问你是否存在一个整数i,满足i*(i+1)/2=n。
若存在,输出"YES",否则输出"NO".
1<=n<=500
Translated by @稀神探女
题目描述
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The nn -th triangular number is the number of dots in a triangle with nndots on a side.
. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular\_number).
Your task is to find out if a given integer is a triangular number.
输入输出格式
输入格式:
The first line contains the single number nn ( 1<=n<=5001<=n<=500 ) — the given integer.
输出格式:
If the given integer is a triangular number output YES, otherwise output NO.
输入输出样例

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int main(){
scanf("%d",&n);
for(int i=;i<=n;i++)
if(i*i+i==*n){
cout<<"YES";
return ;
}
cout<<"NO";
}
CF47A Triangular numbers的更多相关文章
- Triangular numbers
http://codeforces.com/problemset/problem/47/A Triangular numbers time limit per test 2 seconds memor ...
- Triangular Sums
描述 The nth Triangular number, T(n) = 1 + … + n, is the sum of the first n integers. It is the number ...
- codeforces 192A Funky Numbers
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- Project Euler 44: Find the smallest pair of pentagonal numbers whose sum and difference is pentagonal.
In Problem 42 we dealt with triangular problems, in Problem 44 of Project Euler we deal with pentago ...
- Triangular Sums 南阳acm122
Triangular Sums 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 The nth Triangular number, T(n) = 1 + … + n ...
- Gamma函数是如何被发现的?
学过微积分的人,肯定都接触过Euler积分,按教科书上的说法,这是两种含有参变量的定积分,但其实没那么玄乎,它们只是两个函数.其中第一型Euler积分叫\(B\)-函数,第二型Euler积分叫\(\G ...
- 32-语言入门-32-Triangular Sums
题目地址: http://acm.nyist.net/JudgeOnline/problem.php?pid=122 描述The nth Triangular number, T(n) = 1 ...
- The Hundred Greatest Theorems
The Hundred Greatest Theorems The millenium seemed to spur a lot of people to compile "Top 100& ...
- 【南阳OJ分类之语言入门】80题题目+AC代码汇总
小技巧:本文之前由csdn自动生成了一个目录,不必下拉一个一个去找,可通过目录标题直接定位. 本文转载自本人的csdn博客,复制过来的,排版就不弄了,欢迎转载. 声明: 题目部分皆为南阳OJ题目. 代 ...
随机推荐
- C语言之基本算法41—字符串匹配问题
//字符串匹配问题 /* =============================================================== 题目:输入两字符串S,T,输出在S中存在但在T ...
- GIT 源码管理-简介
关于GIT GIT 是一个分布式版本控制软件,最初由林纳斯·托瓦兹(Linus Torvalds)创作,于2005年以GPL发布.最初目的是为更好地管理Linux内核开发而设计.是目前世界上最先进的分 ...
- sql server drop login failed
https://stackoverflow.com/questions/37275/sql-query-for-logins https://www.mssqltips.com/sqlserverti ...
- tflearn Training Step每次 We will run it for 10 epochs (the network will see all data 10 times) with a batch size of 16. n_epoch=10, batch_size=16
Training TFLearn provides a model wrapper 'DNN' that can automatically performs a neural network cla ...
- 6.11Realm简介
CasRealm 统一认证授权中心 跟单点登录有关的.IniRealm 静态文件
- solaris 10 关闭ftp、telnet
安装solaris10,启动后发现找不到ftp.telnet的关闭方法, 管理命令 svcadm(服务状态管理,启动.停止等) # svcs 查看当前所有的服务状态,可以使用|管道符重定向作更个性化的 ...
- POJ3414 Pots
题目: 给你两个容器,分别能装下A升水和B升水,并且可以进行以下操作 FILL(i) 将第i个容器从水龙头里装满(1 ≤ i ≤ 2); DROP(i) 将第i个容器抽干 ...
- CI中的分页
根据MVC的思想,分页是需要传数据到模型中,把页码传过去,在模型中根据页码分配: 更多分页类函数可以通过CI手册的分页类查看: $this -> load ->library('pagin ...
- JAVA基本数据类型转换的注意事项
JAVA中基本数据类型: 类型: 字节: 范围: 默认值: byte 1 -128~127 0 short 2 -32768~32767 0 char 2 0~65535 '\u0000' int 4 ...
- javascript的基础知识及面向对象和原型属性
自己总结一下javascript的基础知识,希望对大家有用,也希望大家来拍砖,毕竟是个人的理解啊 1.1 类型检查:typeof(验证数据类型是:string) var num = 123; cons ...