// https://pydefis.callicode.fr/defis/C25_4_42/txt #include #include #include #include #include using namespace std; const set condition = {2, 4}; map compte; int main() { for(size_t i = 1; i <= 1000; i++) for(size_t j = i + 1; j <= 1000; j++) for(size_t k = j + 1; k <= 1000; k++) { string somme = to_string(i + j + k); string produit = to_string(i * j * k); set st; for(char c : somme) st.insert(c - '0'); for(char c : produit) st.insert(c - '0'); if(st == condition) { //cout << i << ' ' << j << ' ' << k << '\n'; string globale = to_string(i) + " " + to_string(j) + " " + to_string(k); int quatres = count(globale.begin(), globale.end(), '4'); compte[globale] = quatres; } } for(auto element : compte) cout << element.first << " : " << element.second << '\n'; return 0; }