2887: Number of divisible values by 3, 5, and 7
- View
- Submit
- Statistics
- Prompt
- Question
-
Total time limit:
-
1000 ms
-
Memory limit:
-
65536kB
-
Description
-
Enter an integer to determine whether it can be divisible by 3, 5, 7, and output the following information:
1. It can be divisible by 3, 5, and 7 at the same time (3, 5, and 7 are output directly, with a space in the middle of each number );
2. It can be divided by two numbers (two numbers are output, smaller ones are in front and larger ones are in the back. Example: 3 5, 3 7, or 5 7, separated by spaces)
3. Can be divisible by one of the numbers (output this divisor)
4. It cannot be divisible by any number. (lowercase characters 'n' are output, excluding single quotation marks)
-
Input
-
A number
-
Output
-
A row of numbers, arranged in ascending order, including the divisor numbers 3, 5, and 7. The numbers are separated by spaces.
-
Sample Input
-
0515105
-
Sample output
-
3 5 753 53 5 7
#include<stdio.h>#include<stdlib.h>int main(){int n;while(scanf("%d",&n) != EOF){if(n%3==0 && n%5==0 && n%7==0){printf("%d %d %d\n",3,5,7);}else if(n%3==0 && n%5==0){printf("%d %d\n",3,5);}else if(n%5==0 && n%7==0){printf("%d %d\n",5,7);}else if(n%3==0 && n%7==0){printf("%d %d\n",3,7);}else if(n%3==0){printf("%d\n",3);}else if(n%5==0){printf("%d\n",5);}else if(n%7==0){printf("%d\n",7);}}return 0;}