Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cmath>
- using namespace std;
- int main()
- {
- long long int n,s=0,x,nrcif=0,nr=0;
- int p=1;
- cin>>n;
- x=n;
- while (x)
- {
- s+=x%10;
- nrcif++;
- x/=10;
- }
- while(nrcif!=0)
- {
- int aux=(n/p)%10;
- while (aux>9)
- aux/=10;
- if ((s-aux)%3==0)
- {
- nr++;
- }
- p*=10;
- nrcif--;
- }
- cout<<nr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement