Submission #1276278

#TimeUsernameProblemLanguageResultExecution timeMemory
1276278SmuggingSpunLun (COCI19_lun)C++20
50 / 50
2 ms576 KiB
#include<bits/stdc++.h> #define taskname "A" using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } int n, p; cin >> n; vector<int>d; for(int i = 0; i < n; i++){ char c; cin >> c; if(c == 'x'){ d.push_back(-1); p = i; } else{ d.push_back(c - '0'); } } for(int i = 0; i < 10; i++){ d[p] = i; vector<int>D = d; for(int j = n - 2; j > -1; j -= 2){ if((D[j] <<= 1) > 9){ D[j] -= 9; } } int S = 0; for(int j = 0; j + 1 < n; j++){ S += D[j]; } if((S * 9) % 10 == D[n - 1]){ return cout << i, 0; } } }

Compilation message (stderr)

lun.cpp: In function 'int main()':
lun.cpp:7:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...