每日一九度之 题目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后砍掉一半,直到该数 ...
随机推荐
- static单利模式
// // main.m // 01-文件管理器 // // Created by apple on 14-3-21. // Copyright (c) 2014年 apple. All ri ...
- Python生成8位随机密码
#!/usr/bin/env python # -*- coding: utf- -*- import random import string #第一种方法 seed = "1234567 ...
- DNS域名解析
之前用的是DNSPOD.CN的解析,没什么问题. 因为想根据不同国家做服务器解析(欧洲,亚洲,美国) 然后就转到DNSPOD.com里面有按国家来分的. 但是欧洲那边反应,每天断断续续会不能访问网站. ...
- __int64和long long输入输出
__int64 num; scanf("%I64d", &num); printf("%I64d\n", num); long long num; sc ...
- hdu(1171)多重背包
hdu(1171) Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- Andriod环境搭建
安卓是一款现在在移动端十分流行的系统,本人出于好奇心,希望彻底了解安卓的开发技. 首先了解一下安卓的系统构架,安卓大致分为四层架构,五块区域: 1.Linux内核层 Andriod是基于Linux2. ...
- paper 79:MATLAB函数,interp1
在matlab中有一个interp1()函数,可以帮助解决问题,具体情况如下:MATLAB中的插值函数为interp1,其调用格式为: yi= interp1(x,y,xi,'method') 其中x ...
- form文件上传,防止页面刷新
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>文件上传 ...
- 用VS2010编C#程序扫盲
0. Properties文件夹 定义你程序集的属性 项目属性文件夹 一般只有一个 AssemblyInfo.cs 类文件,用于保存程序集的信息,如名称,版本等,这些信息一般与项目属性面板中的数据对应 ...
- SQL2005中的事务与锁定(二)- 转载
------------------------------------------------------------------------ -- Author : HappyFlyStone ...