Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_set>
- #include <fstream>
- #include <cmath>
- using namespace std;
- int main() {
- unordered_set<int> my_set;
- int a, b, c, d, e;
- ifstream in("eqs.in");
- in >> a >> b >> c >> d >> e;
- in.close();
- for (int i = -50; i <= 50; ++i) {
- for (int j = -50; j <= 50; ++j) {
- if (i && j) {
- my_set.insert(a * pow(i, 3) + b * pow(j, 3));
- }
- }
- }
- int nrsol = 0;
- for (int i = -50; i <= 50; ++i) {
- for (int j = -50; j <= 50; ++j) {
- for (int k = -50; k <= 50; ++k) {
- if (i && j && k) {
- if (my_set.find(c * pow(i, 3) + d * pow(j, 3) + e * pow(k, 3))) != my_set.end() {
- ++nrsol;
- }
- }
- }
- }
- }
- ofstream out("eqs.out");
- out << nrsol << '\n';
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement