123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #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;
- }
|