Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long long a[1000];
- int main()
- {
- long long n, i, x, s, p=0;
- cin >> n;
- for (i=1; i<=n; i++)
- {
- cin >> x;
- s=0;
- while (x)
- {
- s+=x%10;
- x/=10;
- }
- a[s]++;
- }
- for (i=1; i<=100; i++)
- if (a[i])
- p+=(a[i]*(a[i]-1))/2;
- cout << p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement