时间限制: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. Spring boot中使用springfox来生成Swagger Specification小结

    Rest接口对应Swagger Specification路径获取办法: 根据location的值获取api   json描述文件 也许有同学会问,为什么搞的这么麻烦,api json描述文件不就是h ...

  2. JAVA字符串的GZIP压缩解压缩

    package com.gzip; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import ...

  3. css less

    LESSCSS是一种动态样式语言,属于CSS预处理语言的一种,它使用类似CSS的语法,为CSS的赋予了动态语言的特性,如变量.继承.运算.函数等,更方便CSS的编写和维护. LESSCSS可以在多种语 ...

  4. js方法和prototype

    JS中的方法可以分为三类 1.对象方法 2.类方法 3.原型方法 例: function People(name) { this.name=name; //对象方法 this.Introduce=fu ...

  5. SQL in查询

    --sal为员工工资 select * from emp;

  6. Splay!

    #include<cstdio> #include<cstdlib> ; ; ; int lim; struct SplayTree { . int sz[maxn]; . ] ...

  7. 分享Centos作为WEB服务器的防火墙规则

    # Firewall configuration written by system-config-firewall # Manual customization of this file is no ...

  8. 夺命雷公狗—angularjs—11—service的基本概念

    我们先来研究下service里面的四大服务.. value 变量 constant  常量 factory   工厂模式 service 服务 <!DOCTYPE html> <ht ...

  9. 夺命雷公狗---2016-linux---3之目录一般作用

    最好文件还是存放在自己的home目录下 建议:在很多时候如果需要系统备份最好去备份boot和etc这两个目录

  10. Ajax错误 “SCRIPT7002: XMLHttpRequest: 网络错误 0x2ef3, 由于出现错误 00002ef3 而导致此项操作无法完成” 的归纳总结

    最近在做Asp.net项目的时候,用Ajax访问服务器数据有时候老是莫名其妙的报错:SCRIPT7002: XMLHttpRequest: 网络错误 0x2ef3, 由于出现错误 00002ef3 而 ...