fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);
  7. cout.tie(0);
  8. freopen("digsuper.inp","r",stdin);
  9. freopen("digsuper.out","w",stdout);
  10. string n;
  11. cin >> n;
  12. long long k;
  13. cin >> k;
  14. long long kq=0;
  15. for(char c: n)
  16. kq=kq+(c-'0');
  17. kq=kq*k;
  18. if(kq%9==0)
  19. {
  20. if(kq==0)
  21. cout << 0;
  22. else
  23. cout << 9;
  24. }
  25. else
  26. cout << (kq % 9);
  27. return 0;
  28.  
  29. }
  30.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Standard output is empty