时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:2109

解决:901

题目描述:

John von Neumann, b. Dec. 28, 1903, d. Feb. 8, 1957, was a Hungarian-American mathematician who made important contributions to the foundations of mathematics, logic, quantum physics, meteorology, science, computers, and game theory. He was noted for a phenomenal memory and the speed with which he absorbed ideas and solved problems. In 1925 he received a B.S. diploma in chemical engineering from Zurich Institute and in 1926 a Ph.D. in mathematics from the University of Budapest, His Ph.D. dissertation on set theory was an important contributions to the subject.
    At the age of 20, von Neumann proposed a new definition of ordinal
numbers that was universally adopted. While still in his twenties, he
made many contributions in both pure and applied mathematics that
established him as a mathematician of unusual depth. His Mathematical
Foundation of Quantum Mechanics (1932) built a solid framework for the
new scientific discipline.
    During this time he also proved the mini-max theorem of GAME THEORY.
He gradually expanded his work in game theory, and with coauthor Oskar
Morgenstern he wrote Theory of Games and Economic Behavior (1944).
    There are some numbers which can be expressed by the sum of
factorials. For example 9, 9 = 1! + 2! + 3! . Dr. von Neumann was very
interested in such numbers. So, he gives you a number n, and wants you
to tell whether or not the number can be expressed by the sum of some
factorials.
Well, it is just a piece of case. For a given n, you will check if there
are some xi, and let n equal to Σt (上标) i=1(下标) xi! (t≥1, xi≥0, xi = xj
<==> i = j)
           t
     即 Σ  xi! (t≥1, xi≥0, xi = xj <==> i = j)
          i=1
    If the answer is yes, say "YES"; otherwise, print out "NO".

输入:

You will get a non-negative integer n (n≤1,000,000) from input file.

输出:

For the n in the input file, you
should print exactly one word ("YES" or "NO") in a single line. No extra
spaces are allowed.

样例输入:
9
2
样例输出:
YES
YES

意思是一个数能不能用一些数的阶乘之和。

因为规定数在1,000,000之内,所以可以直接枚举。

//Asimple
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <cmath>
#include <map>
#include <string>
#include <queue>
#define INF 100000
using namespace std;
const int maxn = ;
typedef long long ll;
int n;
int a[maxn]; int main(){
a[] = ;
for(int i=; i<maxn; i++){
a[i] = i * a[i-];
}
while( ~scanf("%d",&n) ){
for(int i=maxn-; i>=; i--){
if( n >= a[i] ){
n -= a[i];
}
}
printf(n==?"YES\n":"NO\n");
}
return ;
}

最新文章

  1. LTE中的各种ID含义
  2. php实现文件上传与下载(上)
  3. 《learning hard C#学习笔记》读书笔记(19)多线程
  4. Android开发之补间动画、XML方式定义补间动画
  5. JMeter学习-008-JMeter 后置处理器实例之 - 正则表达式提取器(一)概述及简单实例
  6. 商业模拟游戏:&lt;柠檬汁杰克&gt;ios游戏源码
  7. Asp.NET网站Session浅谈
  8. Cacti添加IO模板并监控磁盘IO
  9. UBUNTU 下如何升级 gcc, g++
  10. C#调用matlab出错r6034错误解决方法[转载]
  11. MFC模板CArray及其派生类
  12. Python学习笔记——基础篇【第七周】———类的静态方法 类方法及属性
  13. [转载] Java并发编程:Lock
  14. yii restful和一般路由共存
  15. python 聊天程序(基于UDP)
  16. 【hexo】01安装
  17. Mistwald POJ
  18. WebStrom配置SVN服务
  19. 关于增强的for循环
  20. CentOS 6.5 yum安装mysql5.6或其他版本【默认yum只能安装mysql 5.1】 by jason

热门文章

  1. python password输入
  2. 理解JDBC和JNDI
  3. CollectionView添加头尾部
  4. Sublime 不自动打开上次未关闭的文件 设置方法
  5. Python学习总结19:类(二)
  6. ofbiz进击 第二节。 control 理解与创建
  7. Java的正则表达式
  8. HDU 1402 A * B Problem Plus(FFT)
  9. 查看在线EBS用户的相关信息
  10. inline-block去掉空白距离的方法