Advertisement
Iqura

Untitled

Jan 25th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long n,k,q=0,m=0;
  4. string str="";
  5. int main()
  6. {
  7.     ios_base::sync_with_stdio(false);
  8.    cin.tie(false); cout.tie(false);
  9.     cin>>n>>k;
  10.     m=n*k;
  11.     str=to_string(m);
  12.     while(str.length()>1){
  13.  
  14.         for(int i=0;i<str.length();i++){
  15.             q+=str[i]-'0';
  16.  
  17.         }
  18.         //cout<<q<<endl;
  19.         str=to_string(q);
  20.     q=0;
  21.     }
  22.  
  23.     cout<<str;
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement