-
-
Title Description:
-
John von Neumann, B. Dec, 1903, D. Feb. 8, 1957, was a hungarian-american mathematician who made important contributio NS to the foundations of mathematics, logic, quantum physics, meteorology, science, computers, and game theory. He is 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 T He University of Budapest, he Ph.D. dissertation on set theory is an important contributions to the subject.
At the age of, von Neumann proposed a new definition of ordinal numbers, is universally adopted. While still in the He twenties, he made many contributions in both pure and applied mathematics that established him as a mat Hematician 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 on game theory, and with coauthor Oskar Morgenstern he wrote theory of games and economic B Ehavior (1944).
There is 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 if you are whether or not the number can expressed by the sum of some factorial S.
Well, it's just a piece of case. For a given n, you'll check if there is some XI, and let n equal toσt (superscript) i=1 (subscript) xi! (T≥1, xi≥0, xi = XJ <==> i = j)
T
namely σxi! (T≥1, xi≥0, xi = XJ <==> i = j)
I=1
If The answer is yes, say "yes"; Otherwise, print out "NO".
-
Input:
-
You'll get a non-negative integer n (n≤1,000,000) from input file.
-
Output:
-
For the N of the input file, you should print exactly one word ("YES" or "NO") in a single line. No extra spaces is allowed.
-
Sample input:
-
92
-
Sample output:
-
Yesyes
#include <iostream>using namespacestd;intMain () {intf[ One],n; f[0]=1; for(intI=1;i< One; i++) {F[i]=f[i-1]*i; } while(cin>>N) { if(n==0) cout<<"NO"<<Endl; Else { for(intI=Ten; i>=0; i--){ if(n>=F[i]) n-=F[i]; } if(n==0) cout<<"YES"<<Endl; Elsecout<<"NO"<<Endl; } } return 0;}
1038.sum of Factorials