http://codeforces.com/problemset/problem/47/A
AC代码:
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int p[200000]; int main() { int n,i,x; memset(p,0,sizeof(p)); for(i = 1; i <= 500; i++) { x = i*(i+1)/2; p[x] = 1; } while(scanf("%d",&n)!=EOF) { if(p[n] == 1) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }