fork(28) download
  1. #include <iostream>
  2. #include <utility>
  3. #include <boost/multiprecision/cpp_int.hpp>
  4.  
  5. using boost::multiprecision::cpp_int;
  6. using namespace std;
  7. int main()
  8. {
  9. cpp_int a,sum;
  10. cin >> a;
  11. sum=0;
  12. while(a>0){
  13. sum+=a%10;
  14. a/=10;
  15. }
  16. cout << sum;
  17. }
  18.  
Success #stdin #stdout 0s 3528KB
stdin
123456789123456789123456789123456789123456789123456789123456789
stdout
315