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题目. 代 ...
随机推荐
- 《从零開始学Swift》学习笔记(Day48)——类型检查与转换
原创文章,欢迎转载.转载请注明:关东升的博客 继承会发生在子类和父类之间,是一系列类的继承关系. 比如:Person是类层次结构中的根类.Student是Person的直接子类.Worker是Pers ...
- Spring进行表单验证
转自:https://www.tianmaying.com/tutorial/spring-form-validation 开发环境 IDE+Java环境(JDK 1.7或以上版本) Maven 3. ...
- 你要的 React 面试知识点,都在这了
摘要: 问题很详细,插图很好看. 原文:你要的 React 面试知识点,都在这了 作者:前端小智 Fundebug经授权转载,版权归原作者所有. React是流行的javascript框架之一,在20 ...
- HUdson2092整数解
2019-05-17 16:04:37 加油,坚持就是胜利,fightting m / i的情况,i可能等于0 #include <bits/stdc++.h> using namespa ...
- 44.Qt通过子类化qstyle实现自定义外观
main.cpp #include <QtGui> #include "brozedialog.h" #include "bronzestyle.h" ...
- AndroidStudio项目CMakeLists解析
# For more information about using CMake with Android Studio, read the# documentation: https://d.and ...
- layui新手使用
1,首先最重要的是引入官方的layui.js layui.css文件 2,在自己的项目中新建一个目录 再在该目录下建一个js文件,js中写入 layui.define(['layer', 'form ...
- poj1111 Image Perimeters 广搜
题目大意: 输入一个矩阵,再输入其中一个“X”的位置(从1开始).从该位置向八个方向扩展,如果是“X”就可以并在一起.问最后得到的模块的周长是多少. 解题思路: 按照广搜的思路来做.用一个二维的数组标 ...
- Thread pool引起的程序连接数据库响应慢
数据库版本:percona-mysql 5.6.16 在很长一段时间,都会出现程序连接数据库,出现响应慢的情况,正常在几到几十毫秒之间,但是偶尔会出现上百毫秒的情况: 开始由于开发重新设置并调整过程 ...
- JDK1.7源码阅读tools包之------ArrayList,LinkedList,HashMap,TreeMap
1.HashMap 特点:基于哈希表的 Map 接口的实现.此实现提供所有可选的映射操作,并允许使用 null 值和 null 键.(除了非同步和允许使用 null 之外,HashMap 类与 Has ...