【ブルーブリッジ杯試験前突撃】第10回ブルーブリッジ杯省試合C/C++大学B組試験問題D数の分解
6314 ワード
2019 3 ,
2 4, ?
3 , 1000+1001+18
1001+1000+18 。
,
( dfs , !)
,
2 4, while
,
#include
using namespace std;
bool b[2025];
int ans;//
int main(){
int a=2019/3;
// 2019 2 4 , true;
for(int i=1;i<=2019;i++){
int x=i;
while(x){
int y=x%10;
if(y==2||y==4){
b[i]=true;
break;
}
x=x/10;
}
}
// 2 3 5 2 5 3 , , 673,1346,2019 2019 2019 2019, ,
for(int i=1;i<673;i++){
for(int j=i+1;j<1346;j++){
for(int k=j+1;k<2019;k++){
if(!b[i]&&!b[j]&&!b[k]&&i+j+k==2019){
ans++;
}
}
}
}
cout<<ans<<endl;
return 0;
}
/*
40785
*/
٩(๑❛ᴗ❛๑)۶