Problem solving technique:Patten
1=1 10=1+0=1 19=1+9=10=1+0=1
2=2 11=1+1=2 20=2+0=2
3=3 12=1+2=3 21=2+1=3
4=4 13=1+3=4 22=2+2=4
5=5 14=1+4=5 23=2+3=5
6=6 15=1+5=6 24=2+4=6
7=7 16=1+6=7 25=2+5=7
8=8 17=1+7=8 26=2+6=8
9=9 18=1+8=9 27=2+7=9
After 9th interval we got same digital root
///Bismillahir Rahmanir Rahim
///Author: Tanvir Ahmmad
///CSE,Islamic University,Bangladesh
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<iterator>
#include <functional> ///sort(arr,arr+n,greater<int>()) for decrement of array
/*every external angle sum=360 degree
angle find using polygon hand(n) ((n-2)*180)/n*/
///Floor[Log(b) N] + 1 = the number of digits when any number is represented in base b
using namespace std;
typedef long long ll;
int main()
{
ll tst,k,x;
cin>>tst;
while(tst--)
cin>>k>>x,cout<<((k-1)*9)+x<<endl;
return 0;
}
///Alhamdulillah
Problem Link:https://codeforces.com/contest/1107/problem/B
Comments
Post a Comment