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