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题目. 代 ...
随机推荐
- 黑马day01 笔记
一.xml语法 1.文档声明 用来声明xml的基本属性,用来指挥解析引擎怎样去解析当前xml 通常一个xml都要包括而且仅仅能包括一个文档声明 xml的文档必须在整个xml ...
- 0x51 线性DP
数据结构没什么好写的..分块和整体二分还有点分学得很懂..果然我还是比较适合这些东西 poj2279 奇怪题,我的想法就是五维记录最边上的一斜排,会M,结果的的确确是锻炼思维的,正解并不是DP2333 ...
- 【转】git rebase简介(基本篇)
原文网址:http://blog.csdn.net/hudashi/article/details/7664631/ 原文: http://gitbook.liuhui998.com/4_2.html ...
- Linux Shell Scripting Cookbook 读书笔记 1
本系列文章为<Linux Shell Scripting Cookbook>的读书笔记,只记录了我觉得工作中有用,而我还不是很熟练的命令 书是很好的书,有许多命令由于我比较熟悉,可能就没有 ...
- python之路——二分查找算法
楔子 如果有这样一个列表,让你从这个列表中找到66的位置,你要怎么做? l = [2,3,5,10,15,16,18,22,26,30,32,35,41,42,43,55,56,66,67,69,72 ...
- 初学struts2杂乱笔记
1.在web.xml文件里定义struts2里的一个过滤类org.apache.struts2.dispatcher.FilterDispatcher 2.在src目录下创建struts.xml文件, ...
- 微信小程序开发之animation动画实现
1. 创建动画实例 wx.createAnimation(OBJECT) 创建一个动画实例animation.调用实例的方法来描述动画.最后通过动画实例的export方法导出动画数据传递给组件的ani ...
- 第五周课后作业——适用于人工智能的visual studio 的创新分析
个人觉得作业布置的(2)(3)(4)(5)的顺序并不合理,我将以(5)(2)(3)(4)的顺序开展我的分析. 创新的定义是做出一些改变或创造出新的东西,既是过程,也是结果.这是一个很泛的概念,所以去问 ...
- Goldengate升级之目标端(replicat端)升级
转自红黑联盟Goldengate升级之目标端(replicat端升级 要升级replicat端的原因为:目标端OGG软件版本与源端OGG软件版本不同,在实际生产应用中,经常发现replicat端事务丢 ...
- 【Oracle】三种方式查看SQL语句的执行计划
查看执行计划的方式有三种: EXPLAIN PLAN .V$SQL_PLAN .SQL*PLUS AUTOTRACE 1.EXPLAIN PLAN: 显示执行相应语句时可以使用的理论计划 读取执行计划 ...