732A - Buy a Shovel - CodeForces Solution


brute force constructive algorithms implementation math *800

Please click on ads to support us..

Python Code:

k,r = map(int,input().split())
s = 1
t = k
while t % 10 != 0 and (t % 10)- r != 0:
    s += 1
    t = s * k
print(s)

C++ Code:

//
// Created by erefa on 1/31/2023.
//

#include "bits/stdc++.h"
using namespace std;
int main()
{
    int k , r , num=0 ;
    bool flag= true;
    cin>>k>>r;
    while (flag)
    {
        num++;
        if(num*k%10==0||num*k%10==r)
            flag= false;
    }

    cout<<num;
    return 0;
}


Comments

Submit
0 Comments
More Questions

109A - Lucky Sum of Digits
864C - Bus
626B - Cards
1221A - 2048 Game
1374D - Zero Remainder Array
1567C - Carrying Conundrum
1029C - Maximal Intersection
922C - Cave Painting
811C - Vladik and Memorable Trip
1589C - Two Arrays
1510K - King's Task
126B - Password
462A - Appleman and Easy Task
839C - Journey
622A - Infinite Sequence
659C - Tanya and Toys
1266A - Competitive Programmer
234C - Weather
1332C - K-Complete Word
525C - Ilya and Sticks
1555C - Coin Rows
1324C - Frog Jumps
715A - Plus and Square Root
774D - Lie or Truth
1186D - Vus the Cossack and Numbers
505B - Mr Kitayuta's Colorful Graph
1324D - Pair of Topics
157B - Trace
34C - Page Numbers
279A - Point on Spiral