Submission #100357

#TimeUsernameProblemLanguageResultExecution timeMemory
100357OrtLun (COCI19_lun)C++11
40 / 50
3 ms384 KiB
#include<algorithm> #include<iostream> #include<string> #include<vector> #include<cctype> using namespace std; string s; vector<int> sv; int n; bool t; int main() { cin.sync_with_stdio(0); cin.tie(0); cin >> n; cin >> s; reverse(s.begin(),s.end()); for(int i=0;i<n;i++) { if(isdigit(s[i])) { if(i%2) { int num = s[i]-'0'; num *= 2; if(num>9) num = (num%10) + (num/10); sv.push_back(num); } else sv.push_back(s[i]-'0'); } else {sv.push_back(-1); if(i%2) t=1;} } long long sum = 0; for(int i=0;i<n;i++) sum += (long long)(sv[i]!=-1?sv[i]:0); if(!t) cout << (sum*9)%10; else cout << ((sum*9)%10) /2; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...