12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #include <stdio.h>
- int factorial(int n) {
- int fact = 1;
- int i;
- for (i = 1; i <= n; i++) {
- fact *= i;
- }
- return fact;
- }
- int main() {
- int num, originalNum, sum = 0;
- int temp, power;
- scanf("%d", &num);
- originalNum = num;
- printf("%d,", originalNum);
- temp = originalNum;
- power = 1;
- while (temp > 0) {
- temp /= 10;
- power *= 10;
- }
- power /= 10;
- while (power > 0) {
- int d = originalNum / power;
- printf("%d!", d);
- sum += factorial(d);
- originalNum %= power;
- power /= 10;
- if (power > 0) {
- printf("+");
- }
- }
- if (sum == num) {
- printf("=%d\nYes\n", num);
- } else {
- printf("=%d\nNo\n", sum);
- }
- return 0;
- }
|