# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106238 | 2019-04-17T15:56:35 Z | hamzqq9 | Lun (COCI19_lun) | C++14 | 3 ms | 384 KB |
#include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<ii,int> #define iiii pair<ii,ii> #define sz(x) ((int) x.size()) #define orta ((bas+son)/2) #define all(x) x.begin(),x.end() #define pw(x) (1<<(x)) #define inf 100000009 #define MOD 998244353 #define N 450 #define M 2500005 #define LOG 20 #define KOK 300 #define EPS 0.0000001 using namespace std; int n; char s[105]; bool valid(int val) { int sum=0; for(int i=1;i<n;i++) { int cur=(s[i]=='x'?val:s[i]-'0'); if((n-i+1)&1) { sum+=cur; } else { cur<<=1; sum+=cur%10; sum+=cur/10; } } sum=sum*9%10; int last=(s[n]=='x'?val:s[n]-'0'); return last==sum; } int main() { scanf("%d",&n); scanf("%s",s+1); for(int i=0;i<10;i++) { if(valid(i)) { printf("%d",i); return 0; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |