time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are those that are representable as a sum of two triangular numbers.

A well-known hipster Andrew adores everything funky and cool but unfortunately, he isn't good at maths. Given number n, help him define whether this number can be represented by a sum of two triangular numbers (not necessarily different)!

Input

The first input line contains an integer n (1 ≤ n ≤ 109).

Output

Print "YES" (without the quotes), if n can be represented as a sum of two triangular numbers, otherwise print "NO" (without the quotes).

Examples
input
256
output
YES
input
512
output
NO
Note

In the first sample number .

In the second sample number 512 can not be represented as a sum of two triangular numbers.

#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
#define f(x) (x)*(x+1)/2
int main()
{ int i=,j=,n;
bool flag=false;
while(~scanf("%d",&n))
{
flag=false;
for(i=;f(i)+f(j)<=n;i++)
{
for(j=i;f(i)+f(j)<=n;j++)
{
if(f(i)+f(j)==n)
{
printf("YES\n");
flag=true;
break;
}
}
if(flag)
break;
j=;
}
if(!flag)
printf("NO\n");
}
return ;
}

codeforces 192A Funky Numbers的更多相关文章

  1. CodeForces 55D "Beautiful numbers"(数位DP+离散化处理)

    传送门 参考资料: [1]:CodeForces 55D Beautiful numbers(数位dp&&离散化) 我的理解: 起初,我先定义一个三维数组 dp[ i ][ j ][ ...

  2. Codeforces 878 E. Numbers on the blackboard

    Codeforces 878 E. Numbers on the blackboard 解题思路 有一种最优策略是每次选择最后面一个大于等于 \(0\) 的元素进行合并,这样做完以后相当于给这个元素乘 ...

  3. Codeforces 55D. Beautiful numbers(数位DP,离散化)

    Codeforces 55D. Beautiful numbers 题意 求[L,R]区间内有多少个数满足:该数能被其每一位数字都整除(如12,24,15等). 思路 一开始以为是数位DP的水题,觉得 ...

  4. CodeForces 151B Phone Numbers

     Phone Numbers Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Sub ...

  5. codeforces 55D - Beautiful numbers(数位DP+离散化)

    D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

  6. Codeforces 165E Compatible Numbers(二进制+逆序枚举)

    E. Compatible Numbers time limit per test 4 seconds memory limit per test 256 megabytes input standa ...

  7. codeforces Gym 100338E Numbers (贪心,实现)

    题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include< ...

  8. CodeForces 165E Compatible Numbers(位运算 + 好题)

    wo integers x and y are compatible, if the result of their bitwise "AND" equals zero, that ...

  9. CodeForces 55D Beautiful numbers

    D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

随机推荐

  1. ADFS 2.0 配置简介 PartⅠ – 安装ADFS

        Active Directory Federation Service 也即联盟身份认证服务是微软的单点登录解决方案 (SSO),配置步骤相当多,中文资料也比较少,写在这里希望对后来人有所帮助 ...

  2. sqlclr返回数据集案例

    ----------------------------------------------返回一张表,但只有一条数据,最后一次设置的. [Microsoft.SqlServer.Server.Sql ...

  3. [每日一题] OCP1z0-047 :2013-08-01 正则表达式--- REGEXP_REPLACE 函数

    这题又是考正则表达式,我们先根据题意,操作如下: hr@OCM> col "PHONE NUMBER" for a50 hr@OCM> SELECT phone_num ...

  4. HttpTest4Net

    HttpTest4Net HttpTest4Net是一款基于C#实现的和HTTP压力测试工具,通过工具可以简单地对HTTP服务进行一个压力测试.虽然VS.NET也集成了压力测试项目,但由于VS自身占用 ...

  5. win8 客户端源码

    博客园cnblogs for win8 托管到GitHub开源   中午研究了下GitHub ,然后把博客园cnblogs win8 客户端源码放到了上面. 源码网址是: https://github ...

  6. test maekdown 2

    Package Control Messages Markdown Preview: Sublime Text 2/3 Markdown Preview ======================= ...

  7. [原]逆向iOS SDK -- “添加本地通知”的流程分析

    观点: 代码面前没有秘密 添加通知的 Demo 代码 - (void)scheduleOneLocalNotification { [[UIApplication sharedApplication] ...

  8. MVC4中使用SignalR

    MVC4中使用SignalR 前言 周末在偶尔翻阅微软官网的时候看到Getting Started with SignalR and MVC 4此篇文章,知道了signalr这个东西,貌似这个出来很长 ...

  9. 一键搭键php网站环境的系统

    QzzmServer v2.0正式版发布 首先,感谢网友的热情的测评及反馈,现QzzmServer 2.0正式版已发布.有些朋友反馈制作一个服务器专用版本,在下已将此列入计划中,敬请大家耐心等候. Q ...

  10. javascript中的promise和deferred:实践(二)

    javascript中的promise和deferred:实践(二) 介绍: 在第一节呢,我花了大量的时间来介绍promises和deferreds的理论.现在呢,我们来看看jquery中的promi ...