题目描述
本题为填空题,只需要算出结果后,在代码中使用输出语句将所填结果输出即可。
把 2019 分解成 3 个各不相同的正整数之和,并且要求每个正整数都不包含数字 2 和 4,一共有多少种不同的分解方法?
注意交换 3 个整数的顺序被视为同一种方法,例如 1000+1001+18 和 1001+1000+18
#include<iostream>
using namespace std;
bool f(int x){
while(x){
if(x>10){
int temp=x%10;
x/=10;
if(temp==2||temp==4){
return true;
}
}else{
if(x==2||x==4){
return true;
}
return false;
}
}
}
int main(){
int a=2019;
int cnt=0;
int b;
for(int i=1;i<2019;i++){
for(int j=1;j<2019;j++){
b=2019-i-j;
if(b>0=0=0=0jbb)){
cnt++;
}
}
}
cout<<cnt/6; //答案:40785
return 0;
}
被视为同一种。