Submission #106171

#TimeUsernameProblemLanguageResultExecution timeMemory
106171sofhiasouzaSequence (BOI14_sequence)C++14
25 / 100
41 ms512 KiB
#include <bits/stdc++.h> using namespace std; int main() { int k, a; string s; cin >> k; for(int i = 0 ; i < k ; i++) cin >> a; k--; stringstream ans; ans << k; ans >> s; if(k == 0 and a != 0) cout << a << endl; else if(a == 0) { long long int p = 0; for(int i = 1 ; i <= s.size() ; i++) p += (long long int)pow(10, s.size() - i); if(k == 0) cout << 10 << endl; else if(p >= k+1) cout << (long long int)pow(10, s.size()) << endl; else cout << (long long int)pow(10, s.size()+1) << endl; } else if(a == 9) { long long int p = 0, p2 = 0; p2 += (long long int)pow(10, s.size() - 1); for(int i = 2 ; i <= s.size() ; i++) p += (long long int)pow(10, s.size() - i); p2 += p; if(s.size() == 1) cout << 89 << endl; else if((long long int)p + (long long int)pow(10, s.size()-1) >= k+1) cout << (long long int)pow(10, s.size()-1)*9 - p << endl; else cout << (long long int)pow(10, s.size())*9 - p2 << endl; } else cout << (long long int)pow(10, s.size())*a << endl; }

Compilation message (stderr)

sequence.cpp: In function 'int main()':
sequence.cpp:17:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 1 ; i <= s.size() ; i++) p += (long long int)pow(10, s.size() - i);
                   ~~^~~~~~~~~~~
sequence.cpp:26:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 2 ; i <= s.size() ; i++) p += (long long int)pow(10, s.size() - i);
                   ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...