1 条题解
-
0xuyifeng LV 10 MOD @ 2017-08-24 16:33:31
---------------------------------------------AC code---------------------------------------------
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int MAXX = 1000005; const int MAXN = 200005; int n, k, m, a[MAXN], lastans; struct Q{ int opt, l, r; }q[MAXN]; int p_list[MAXX], p_num; bool prime[MAXX]; void Prime(){ memset(p_list, 0, sizeof p_list); memset(prime, 0, sizeof prime); p_num = 0; prime[0] = prime[1] = 1; for(int i = 2; i <= MAXX-5; i++){ if(!prime[i]) p_list[++p_num] = i; for(int j = 1; j <= p_num; j++){ if(i * p_list[j] > MAXX-5) break; prime[i*p_list[j]] = 1; if(i % p_list[j] == 0) break; } } } //a ^ b = c <==> a ^ c = b <==> b ^ c = a int main(){ Prime(); scanf("%d%d%d", &n, &k, &m); for(int i = 1; i <= n; i++){ scanf("%d", &a[i]); if(prime[a[i]]) a[i] = (1<<30); } for(int i = 1; i <= m; i++) scanf("%d%d%d", &q[i].opt, &q[i].l, &q[i].r); for(int i = 1; i <= m-1; i++){ if(q[i].opt == 1){ int t1 = q[i+1].opt ^ 1, t2 = q[i+1].opt ^ 2; if(!prime[t1]) printf("%d\n", lastans = t1); if(!prime[t2]) printf("%d\n", lastans = t2); } if(q[i].opt == 2 && !prime[q[i].r]) a[q[i].l] = q[i].r; if(q[i].opt == 2 && prime[q[i].r]) a[q[i].l] = (1<<30); q[i+1].opt ^= lastans, q[i+1].l ^= lastans, q[i+1].r ^= lastans; } if(q[m].opt == 1){ sort(a+q[m].l, a+q[m].r+1); printf("%d\n", a[k+q[m].l-1]); } return 0; }
- 1
信息
- 难度
- (无)
- 分类
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 通过率
- ?
- 上传者