- #include<bits/stdc++.h>
- using namespace std;
- int n;
- queue<int> q;
- int main()
- {
- cin>>n;
- int a;
- for(int i=0;i<n;i++)
- {
- cin>>a;
- q.push(a);
- }
- while(q.size()>1)
- {
- int t=q.front();
- if(t%2==0)
- {
- q.push(t);
- q.pop();
- q.pop();
- n--;
- }
- else
- {
- q.push(t);
- q.pop();
- }
- /*for(int j:v)
- cout<<j<<' ';
- cout<<endl;*/
- }
- /*for(int i:v)
- cout<<i<<endl;*/
- cout<<q.front()<<endl;
- return 0;
- }
複製代碼 |