每日一九度之 题目1038:Sum of Factorials
时间限制: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的更多相关文章
- 每日一九度之题目1016:火星A+B
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5346 解决:1464 题目描述: 读入两个不超过25位的火星正整数A和B,计算A+B.需要注意的是:在火星上,整数不是单一进制的, ...
- 每日一九度之 题目1076:N的阶乘
时间限制:3 秒 内存限制:128 兆 特殊判题:否 提交:7601 解决:2749 题目描述: 输入一个正整数N,输出N的阶乘. 输入: 正整数N(0<=N<=1000) 输出: 输入可 ...
- 每日一九度之 题目1043:Day of Week
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7336 解决:2563 题目描述: We now use the Gregorian style of dating in Russia. ...
- 每日一九度之 题目1042:Coincidence
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3007 解决:1638 题目描述: Find a longest common subsequence of two strings. 输入 ...
- 每日一九度之 题目1041:Simple Sorting
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4883 解决:1860 题目描述: You are given an unsorted array of integer numbers. ...
- 每日一九度之 题目1040:Prime Number
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6732 解决:2738 题目描述: Output the k-th prime number. 输入: k≤10000 输出: The k- ...
- 每日一九度之 题目1039:Zero-complexity Transposition
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3372 解决:1392 题目描述: You are given a sequence of integer numbers. Zero-co ...
- 每日一九度之 题目1033:继续xxx定律
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5502 解决:1351 题目描述: 当n为3时,我们在验证xxx定律的过程中会得到一个序列,3,5,8,4,2,1,将3称为关键数, ...
- 每日一九度之 题目1031:xxx定律
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6870 解决:4302 题目描述: 对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数 ...
随机推荐
- SWIFT 闭包的简单使用二
import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: ...
- ORACLE 11G内存管理方式
SGA包含的组件: 组件名 说明 参数 buffer cache 存放从数据文件中读取的数据拷贝,所有用户之间是可以共享的 db_cache_size db_keep_cache_size db_re ...
- Lintcode: Sort Colors II
Given an array of n objects with k different colors (numbered from 1 to k), sort them so that object ...
- IOS Certificates 制作流程 (Adobe FlashBuilder)
看到一个Adobe 官方的PDF 说的非常明白,比自己一步一步总结的要好多了 怎么生成 以及为何生成都有说明 http://help.adobe.com/en_US/ppcompdoc/Adobe_P ...
- JS练习 改变文本框状态
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 汉字转【pinyin】
引言 github地址:aizuyan/pinyin 无意中看到了overtrue/pinyin这个项目,感觉很有意思,这个项目做了这么一件事情: 将汉字转化为拼音 刚看到这里是不是觉得没什么难度,没 ...
- navicat的简单应用
首先 创建连接 主机名 : 可以不写名称随意 主机名/IP地址:localhost或者127.0.0.1 都是本机的意思 端口:默认3306 尽量不要改怕与其余端口重复,如有重名端口系统会报错 ...
- C++Builder 笔记
1.界面窗口如何不显示标题栏? 在Form属性栏里面把BorderStyle的值设为None 2.wchar_t wchar_t是C/C++的字符类型,是一种扩展的存储方式,wchar_t类型主要用在 ...
- [转] HashMap的工作原理
HashMap的工作原理是近年来常见的Java面试题.几乎每个Java程序员都知道HashMap,都知道哪里要用HashMap,知道Hashtable和HashMap之间的区别,那么为何这道面试题如此 ...
- poj: 1004
简单题 #include <iostream> #include <stdio.h> #include <string.h> #include <stack& ...