TAHMID37

tahmid_task_2

Oct 25th, 2020
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. /*  TAHMID RAHMAN
  2.     DAMIAN FOREVER
  3.      MATH LOVER
  4.     NEVER GIVE UP
  5. */
  6. #include<bits/stdc++.h>
  7. using namespace std;
  8. #define pi acos(-1.0)
  9. #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  10. #define ll long long
  11. #define pb push_back
  12. #define fi first
  13. #define se second
  14. #define in insert
  15. #define mp make_pair
  16. #define GCD(a,b) __gcd(a,b);
  17. #define endl "\n"
  18. #define FRU freopen("out.txt","w",stdout)
  19. #define FRO freopen("in.txt","r",stdin)
  20. #define INFLL 9223372036854775807
  21. #define debug 0
  22. #define MAXN   100001
  23. #define ar array
  24. #define lb lower_bound
  25. #define ub upper_bound
  26. const int mxN=2e5;
  27. const int MOD=1e9+7;
  28. template<typename ForwardIterator, typename T>
  29. ForwardIterator first_less_than (ForwardIterator first, ForwardIterator last, T value)
  30. {auto it = std::lower_bound (first, last, value);
  31. return (it == first ? last : --it);}
  32. bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
  33. {
  34.     return (a.second < b.second);
  35. }
  36. #define debugxx(v) {for(auto x:v){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
  37. #define debugx(v){for(auto y:v) {cout<<y<<" ";}cout<<endl;}
  38. ll sum=0;
  39.  
  40. ll dig_sum(string s)
  41. {
  42.  
  43.     if(s.size()!=0)
  44.     {
  45.         sum+=(s[0]-'0');
  46.         return dig_sum(s.substr(1));
  47.     }
  48.  
  49.     return sum;
  50.  
  51. }
  52.  
  53. int main()
  54. {
  55.     string s;
  56.     cin>>s;
  57.     ll k;
  58.     cin>>k;
  59.     ll summ=dig_sum(s);
  60.     //cout<<summ<<endl;
  61.     summ*=k;
  62.  
  63.     if(summ%9==0)
  64.         cout<<9<<endl;
  65.     else
  66.         cout<<summ%9<<endl;
  67.  
  68.  
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
Advertisement
Add Comment
Please, Sign In to add comment