Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- int n, m, wynik, k, a2;
- using namespace std;
- int main()
- {
- cin>>n>>m;
- if(n%2==0)
- {
- k=n/2;
- a2=k;
- while(k>0)
- {
- if(a2%m==0)
- {
- wynik=a2;
- break;
- }
- k--;
- a2++;
- }
- }
- else
- {
- k=(n/2);
- a2=k+1;
- while(k>0)
- {
- if(a2%m==0)
- {
- wynik=a2;
- break;
- }
- k--;
- a2++;
- }
- }
- if(wynik==0)
- {
- if((n/1)%m==0)
- {
- cout<<n/1;
- return 0;
- }
- cout<<-1;
- return 0;
- }
- cout<<wynik;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement