Decomposition of the number of 1567 (2019 Blue Bridge province Cup tournament)

Title Description

The x decomposed into three different and positive integers, and each requires a positive integer numbers 2 and 4 are not included, how many different method for decomposing a total of? Note that the order of switching an integer of 3 is considered the same method, for example, when decomposed during 2019, 1000 and 1001 + 1001 + 18 + 1000 + 18 is regarded as the same.

Enter a description

Multiple sets of test data, each set of test data per line.

Per line integer x (0 <x <10000).

Output Description

For each input and output line of the answer.

Sample input

5

Sample Output

0

 

 1 #include<iostream>
 2 using namespace std;
 3 int deside(int n){
 4     int a,b,c,d;
 5     a=n%10;
 6     n=n/10;
 7     b=n%10;
 8     n=n/10;
 9     c=n%10;
10     n=n/10;
11     d=n%10;
12     if(a==2||a==4||b==2||b==4||c==2||c==4||d==2||d==4){
13         return 1;
14     }
15     else{
16         return 0;
17     }
18 }
19 int main(){
20     int m,i,j,k;
21     while(cin>>m){
22         int num=0,p;
23         int choice[m*2];
24         for(i=1;i<m-1;i++){
25             if(deside(i)){
26                 continue;
27             }
28             for(j=i+1;j<m;j++){
29                 int nm=0;
30                 if(deside(j)){
31                     continue;
32                 }
33                 k=m-i-j;
34                 if(k<=0){
35                     continue;
36                 }
37                 if(deside(k)){
38                     continue;
39                 }
40                 if(i==k||j==k){
41                     continue;
42                 }
43                 num++;
44             }
45         }
46         num=num/3;
47         cout<<num<<endl;
48     }
49     return 0;
50 }

 

Guess you like

Origin www.cnblogs.com/zq-dmhy/p/11070213.html