Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9. {
  10. long long int n,s=0,x,nrcif=0,nr=0;
  11. int p=1;
  12. cin>>n;
  13. x=n;
  14. while (x)
  15. {
  16. s+=x%10;
  17. nrcif++;
  18. x/=10;
  19. }
  20. while(nrcif!=0)
  21. {
  22. int aux=(n/p)%10;
  23. while (aux>9)
  24. aux/=10;
  25. if ((s-aux)%3==0)
  26. {
  27. nr++;
  28. }
  29. p*=10;
  30. nrcif--;
  31. }
  32. cout<<nr;
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement