Spoj LASTDIG2 - The last digit re-visited Solution
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include <bits/stdc++.h>
- using namespace std;
- int Modulo(int a, string b)
- {
- int mod = 0;
- for (int i = 0; i <b.size(); i++){
- mod = (mod * 10 + b[i] - '0') % a;}
- return mod;
- }
- int LastDigit(string a,string b)
- {
- int len_a = a.size(), len_b = b.size();
- if ((len_a == 1 && len_b == 1 && b[0] == '0' && a[0] == '0')||(len_b == 1 && b[0] == '0')) return 1;
- if (len_a == 1 && a[0] == '0') return 0;
- return res % 10;
- }
- int main()
- {
- int t,n,i;
- cin>>t;
- while(t--)
- {
- string a,b; cin>>a>>b;
- cout<<LastDigit(a,b)<<endl;
- }
- }
No comments