处女座点名
https://ac.nowcoder.com/acm/contest/329/C
題解:
std
題目已經(jīng)保證了輸入順序,只需要判斷讀入的數(shù)是否比上一個數(shù)大1即可。如果都滿足,就是最后一個數(shù)沒有出現(xiàn)。
BONUS:這題如果不給學(xué)生人數(shù),不順序讀入怎么做呢?
時間復(fù)雜度:?(?)
#include <bits/stdc++.h> using namespace std;int main() {int maxx=0,x=0,t;int n;scanf("%d",&n);while (scanf("%d",&t)==1){x^=t;maxx=max(maxx,t);}for (int i=1;i<=maxx;i++)x^=i;if (x==0) x=maxx+1;printf("%d\n",x);return 0; }?
總結(jié)
- 上一篇: 欧拉降幂(Euler_Power_For
- 下一篇: 处女座的训练