#include<iostream> #include<vector> using namespace std; vector<int>a; // 这道题只能选用左闭右开方法 int search(vector<int>nums,int targer) { int left = 0; int right = nums.size()-1; while(left < right) { int middle = left + (right-left)/2; if(nums[middle]<targer) { left = middle ; } else if(nums[middle]>targer) { right = middle -1; } else { return middle; } } if(targer < nums[0]) { return 0; } else if(targer>nums[nums.size()-1]) { return nums.size(); } else { return left+1; } } int main() { int n; while(1) { cin >> n; a.push_back(n); if(cin.get()=='\n') { break; } } int tag; cin >> tag; int res; res = search(a,tag); cout << res; return 0; }