Source Code
#include <iostream>
using namespace std;

int sum1(int a) {
	int l = 0;
	while (a != 0) {
		l = l + a % 10;
		a = a / 10;
		if (l >= 10)
			l = l / 10;
	}
	return l;
}


int main() {
	int n;
	long long int a;
	int sum=0;
	cin >> n;
	for (int i = 1;i <= n;i++) {
		cin >> a;
		sum = sum + sum1(a);
	}
	cout << sum;
	return 0;
}
Copy
The Tale of a Generous Prince hoodlum awm
GNU G++17
2 ms
664 KB
Wrong Answer