Advertisement
a53

recc_20p

a53
Apr 22nd, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <fstream>
  2. #include <set>
  3. using namespace std;
  4. /// ecuatia: a1*p4+a2*p3+a3*p2+a4*p1=k*x => a1*p4+a2*p3=k*x-(a3*p2+a4*p1)
  5. int main()
  6. {
  7. int n,b,x,k,a1,a2,a3,a4;
  8. ifstream f("recc.in");
  9. f>>n>>b>>x>>k>>a1>>a2>>a3>>a4;
  10. f.close();
  11. int ST,DR,rez=0;
  12. multiset <int> H;
  13. for(int p4=1;p4<=b;++p4)
  14. for(int p3=1;p3<=b;++p3)
  15. H.insert(a1*p4+a2*p3);
  16. for(int p2=1;p2<=b;++p2)
  17. for(int p1=1;p1<=b;++p1)
  18. {
  19. int S=a3*p2+a4*p1;
  20. DR=(k*x-S);
  21. ST=*H.find(DR);
  22. if(ST==DR)
  23. ++rez;
  24. }
  25. ofstream g("recc.out");
  26. g<<rez<<'\n';
  27. g.close();
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement