This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const ll MAXN=1e6+10;
const ll MAXA=1e9+10;
ll n;
string a[MAXN];
ll string_to_int(string s)
{
ll res=0;
ll sz=s.size();
for(ll i=sz-1;i>=0;i--)
{
res*=10;
res+=(s[i]-'0');
}
return res;
}
bool isPalindrome(string s)
{
string revs=s;
reverse(revs.begin(), revs.end());
return s == revs;
}
void read()
{
cin>>n;
for(ll i=1;i<=n;i++)
{
cin>>a[i];
}
}
void solve()
{
ll ans=0;
for(ll i=1;i<=n;i++)
{
string s=a[i];
if(isPalindrome(s))
{
ll cur=string_to_int(s);
ans+=cur;
}
}
cout<<ans<<endl;
}
int main()
{
#ifdef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
read();
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |