Why double coins = (double)(k+l)/m and then ceil(coins) works ↵
And this one faila for case 28↵
↵
#include<bits/stdc++.h>↵
#define ll long long↵
using namespace std;↵
int main()↵
{↵
ll n,m,k,l;↵
cin>>n>>m>>k>>l;↵
↵
ll coins = ceil((double)(k+l)/m);↵
↵
if(k+l > n || coins*m > n)↵
{↵
cout<<"-1"<<endl;↵
}↵
else {↵
cout<<coins<<endl;↵
}↵
//main();↵
↵
}↵
Why double coins = (double)(k+l)/m and then ceil(coins) works ↵
And this one faila for case 28↵
Thanks for help↵
Thanks in advance↵
And this one faila for case 28↵
↵
#include<bits/stdc++.h>↵
#define ll long long↵
using namespace std;↵
int main()↵
{↵
ll n,m,k,l;↵
cin>>n>>m>>k>>l;↵
↵
ll coins = ceil((double)(k+l)/m);↵
↵
if(k+l > n || coins*m > n)↵
{↵
cout<<"-1"<<endl;↵
}↵
else {↵
cout<<coins<<endl;↵
}↵
//main();↵
↵
}↵
And this one faila for case 28↵
Thanks for help
Thanks in advance