Source Code
#include <bits/stdc++.h> 
#define int long long
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define SORT(c) sort(all(c))
#define rSORT(c) sort(rall(c))
#define f first
#define s second
#define pb push_back
#define endl "\n"
using namespace std;
void solve();
int32_t main(){ios::sync_with_stdio(false);cin.tie(0);int t = 1;int i = 1;
    //cin >> t;
    while(t--){//cout<<"_________________________________\n";cout<<"Test case Number: "<<i++<<endl<<endl;
        solve();
    }
}
void solve(){
    int n;cin >> n;
    int ans = 0;
    for(int i = 0;i<n;i++){
        string x;cin >> x;
        for(char j : x){
            ans += (j-'0');
            if(ans >= 10) ans = (ans % 10) + 1;
        }
    }
    cout << ans;
}
Copy
The Tale of a Generous Prince barakat
GNU G++17
23 ms
1.1 MB
Accepted