From 83e060de50e4d52c05639407a0815db10ea3241c Mon Sep 17 00:00:00 2001 From: kirru08 <56930874+kirru08@users.noreply.github.com> Date: Mon, 28 Oct 2019 14:55:23 +0530 Subject: [PATCH] Create footballseason.cpp solution to the problem C of Codeforces Round 592. --- 1244C/footballseason.cpp | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 1244C/footballseason.cpp diff --git a/1244C/footballseason.cpp b/1244C/footballseason.cpp new file mode 100644 index 0000000..8bfed5b --- /dev/null +++ b/1244C/footballseason.cpp @@ -0,0 +1,41 @@ + #include + #define ll long long + + using namespace std; + + int main(void) + { + ll int n, p, w, d; + cin>>n>>p>>w>>d; + ll int wins=0, draws=0, losses=0; + if(p>(n*w) || p0) + { + cout<<-1<<"\n"; + return 0; + } + + else + { + for(draws=0; draws<=w-1; draws++) + { + if((p-draws*d)>=0 && (draws+(p-draws*d)/w)<=n && ((p-draws*d)%w)==0) + { + wins = ((p-draws*d)/w); + losses = n-(draws+wins); + break; + } + } + } + + losses=n-(wins+draws); + + if((wins*w+draws*d)!=p) + { + cout<<-1<<"\n"; + return 0; + } + + cout<