fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. int main() {
  8. int n;
  9. string k;
  10. cin >> n >> k;
  11.  
  12. vector <string> v(n);
  13.  
  14. for (int i = 1; i <= n; i++) {
  15. v[i - 1] = to_string(i);
  16. }
  17.  
  18. sort(v.begin(), v.end());
  19.  
  20. for (int i = 1; i <= n; i++) {
  21. if (k == v[i - 1]) {
  22. cout << i;
  23. }
  24. }
  25.  
  26. return 0;
  27. }
  28.  
  29.  
  30.  
Success #stdin #stdout 0s 5316KB
stdin
25 17
stdout
9