Problem Description
Comprising a given number of columns n integers, ask a first integer number of columns in the first occurrence of the first few.
Input Format
The first row contains an integer n.
The second line contains a non-negative integer n, for a given number of columns, each column count is not greater than 10,000.
The third row contains an integer a, the number to be searched.
Output Format
If a number appears in the column, it is the position of the first occurrence of the output (position numbering begins at 1), otherwise the output -1.
Sample input
6
1 9 4 8 3 9
9
1 9 4 8 3 9
9
Sample Output
2
Data size and convention
1 <= n <= 1000。
#include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <vector> #include <cmath> #include <queue> #include <deque> #include <cmath> #include <map> using namespace std; typedef long long ll; #define INF 0x7fffffff const double inf=1e20; const int maxn=1000+10; const int mod=1e9+7; const double pi=acos(-1); int a[maxn]; int main(){ int n; scanf("%d",&n); int m; for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } int j=-1; scanf("%d",&m); for(int i=1;i<=n;i++){ if(a[i]==m){ j=i; break; } } printf("%d\n",j); return 0; }