Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <set>
- using namespace std;
- /// ecuatia: a1*p4+a2*p3+a3*p2+a4*p1=k*x => a1*p4+a2*p3=k*x-(a3*p2+a4*p1)
- int main()
- {
- int n,b,x,k,a1,a2,a3,a4;
- ifstream f("recc.in");
- f>>n>>b>>x>>k>>a1>>a2>>a3>>a4;
- f.close();
- int ST,DR,rez=0;
- multiset <int> H;
- for(int p4=1;p4<=b;++p4)
- for(int p3=1;p3<=b;++p3)
- H.insert(a1*p4+a2*p3);
- for(int p2=1;p2<=b;++p2)
- for(int p1=1;p1<=b;++p1)
- {
- int S=a3*p2+a4*p1;
- DR=(k*x-S);
- ST=*H.find(DR);
- if(ST==DR)
- ++rez;
- }
- ofstream g("recc.out");
- g<<rez<<'\n';
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement