https://i1.wp.com/eblogarithm.com/wp-content/uploads/2016/10/CodeForces-Round-377-Div-2.png?fit=640%2C360

CodeForces Round #377 (Div. 2), problem: (A) Buy a Shovel Solution in C++

Hi guys , I just solved the CodeForces Round #377 (Div. 2), problem: (A) Buy a Shovel , hope you like it .
You are most welcome to submit any other solution .

 

 

 

#include<bits/stdc++.h>
using namespace std;
int main()
{
int k, r, n1, i, n2, money;
cin>>k>>r;
n1=0;
n2=0;
for(i=0;; i++)
{
money=10*i+r;
if(money%k==0)
n1=money/k;
money=10*i;
if(money%k==0)
n2=money/k;

if(n1!=0 && n2==0)
{
cout<<n1<<endl;
break;
}

if(n2!=0 && n1==0)
{
cout<<n2<<endl; break; } if(n1==0 && n2==0) continue; if(n1>n2)
{
cout<<n2<<endl;
break;
}
else
{
cout<<n1<<endl;
break;
}
}
return 0;
}

(Visited 164 times, 2 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: