Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <unordered_set>
  3. #include <fstream>
  4. #include <cmath>
  5. using namespace std;
  6.  
  7. int main() {
  8. unordered_set<int> my_set;
  9.  
  10. int a, b, c, d, e;
  11. ifstream in("eqs.in");
  12. in >> a >> b >> c >> d >> e;
  13. in.close();
  14.  
  15. for (int i = -50; i <= 50; ++i) {
  16. for (int j = -50; j <= 50; ++j) {
  17. if (i && j) {
  18. my_set.insert(a * pow(i, 3) + b * pow(j, 3));
  19. }
  20. }
  21. }
  22.  
  23. int nrsol = 0;
  24. for (int i = -50; i <= 50; ++i) {
  25. for (int j = -50; j <= 50; ++j) {
  26. for (int k = -50; k <= 50; ++k) {
  27. if (i && j && k) {
  28. if (my_set.find(c * pow(i, 3) + d * pow(j, 3) + e * pow(k, 3))) != my_set.end() {
  29. ++nrsol;
  30. }
  31. }
  32. }
  33. }
  34. }
  35.  
  36. ofstream out("eqs.out");
  37. out << nrsol << '\n';
  38. out.close();
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement