时间限制: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 ;
}

每日一九度之 题目1038:Sum of Factorials的更多相关文章

  1. 每日一九度之题目1016:火星A+B

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5346 解决:1464 题目描述:     读入两个不超过25位的火星正整数A和B,计算A+B.需要注意的是:在火星上,整数不是单一进制的, ...

  2. 每日一九度之 题目1076:N的阶乘

    时间限制:3 秒 内存限制:128 兆 特殊判题:否 提交:7601 解决:2749 题目描述: 输入一个正整数N,输出N的阶乘. 输入: 正整数N(0<=N<=1000) 输出: 输入可 ...

  3. 每日一九度之 题目1043:Day of Week

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7336 解决:2563 题目描述: We now use the Gregorian style of dating in Russia. ...

  4. 每日一九度之 题目1042:Coincidence

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3007 解决:1638 题目描述: Find a longest common subsequence of two strings. 输入 ...

  5. 每日一九度之 题目1041:Simple Sorting

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4883 解决:1860 题目描述: You are given an unsorted array of integer numbers. ...

  6. 每日一九度之 题目1040:Prime Number

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6732 解决:2738 题目描述: Output the k-th prime number. 输入: k≤10000 输出: The k- ...

  7. 每日一九度之 题目1039:Zero-complexity Transposition

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3372 解决:1392 题目描述: You are given a sequence of integer numbers. Zero-co ...

  8. 每日一九度之 题目1033:继续xxx定律

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5502 解决:1351 题目描述:     当n为3时,我们在验证xxx定律的过程中会得到一个序列,3,5,8,4,2,1,将3称为关键数, ...

  9. 每日一九度之 题目1031:xxx定律

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6870 解决:4302 题目描述:     对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数 ...

随机推荐

  1. css 正方体

    <!DOCTYPE html><html lang="zh-cmn-Hans"><head><meta charset="utf ...

  2. 史上最全的css hack(ie6-9,firefox,chrome,opera,safari) (zz)

    在这个浏览器百花争鸣的时代,作为前端开发的我们为了我们漂亮的设计能适应各个浏览器可为煞费苦心,主要体现在javascript和css上面.javascript我这次就不谈了,先说说css.       ...

  3. Swift游戏实战-跑酷熊猫 05 踩踏平台是怎么炼成的

    这节内容我们一起学习下随机长度的踩踏平台的原理是怎么样的. 要点: 平台的组成 我们的平台由3部分组成 左: 中: 右: 其中中间部分是可以无缝衔接的,下面就是两个中间部分衔接在一起 要任何长度的平台 ...

  4. System.Web.HttpContext.Current.Server.MapPath("~/upload/SH") 未将对象引用设置为实例对象

    做项目的时候,System.Web.HttpContext.Current.Server.MapPath("~/upload/SH")   获取路径本来这个方法用的好好的 因为需要 ...

  5. [经典php视频]构建正则表达式解析网页中的图像标记<img>

    这是高洛峰php视频中的一段,视频中一边分析需要的功能,一边构建greg_match函数的参数,边讲解边实战,是非常好的一种构建功能的演示. 你不可能把浩瀚的IT资料都记在脑袋里,也不可能随时随地透过 ...

  6. win7 64位系统下 PL/SQL无法连接的问题

    第一步:下载oracle客户端 由于 PLSQL Developer 没有64位版本,所以在64位系统上运行该程链接64位Oracle时就会报错,笔者为这个问题纠结了好几天,后来通过请教Google ...

  7. html规范总结

    这个链接有规范的html 描述:http://nec.netease.com/standard 相关链接: 1. http://www.zhangxinxu.com/wordpress/2010/09 ...

  8. SQL Server 索引视图 聚簇索引

    创建示例: 朋友的网站速度慢,让我帮忙看下,他用的SQL Server里面 有一个文章表里面有30多万条记录 还有一个用户表里面也差不多17万记录 偏偏当初设计的时候没有冗余字段 很多帖子信息需要JO ...

  9. setInterval 实时驱动界面改变

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  10. android 学习随笔三(测试与单元测试框架)

    测试 1.按岗位: 黑盒测试:测试业务逻辑 白盒测试:测试逻辑方法 2.按测试粒度 方法测试 function 单元测试 unit 集成测试 integration 系统测试 system 3.按暴力 ...