ACdream 1112 Alice and Bob (SG函数)
来源:互联网 发布:修复tf卡数据 编辑:程序博客网 时间:2024/05/21 07:01
题目链接:
ACdream 1112
题意:
给你
规则如下:
若
题解:
对于
对每个数的素因子个数进行操作,即素数可以看做是一个1。
如果我们把
然后所有的情况就可以表示为:
然后在计算
设一个数为
操作的本质其实就是给一些指数降幂,也就是可以把
AC代码:
/** this code is made by LzyRapx* Problem: 1112* Verdict: Accepted* Submission Date: 2017-07-24 17:34:31* Time: 1368MS* Memory: 21196KB*/#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N = 5000005;int flag[N];int sg[100], n;bool vis[100];void make_prime(){ for(int i = 2; i < N; i++) { if(!flag[i]) { for(int j = i + i; j < N; j += i) flag[j] = i; } }}void SG(){ sg[0] = 0; for(int i = 1; i < 100; i++) { memset(vis, false, sizeof(vis)); for(int j = 0; j < i; j++) { vis[sg[j]] = true; } for(int j = 1; j < i; j++){ vis[sg[j] ^ sg[i - j]] = true; } for(int j = 0;;j++) { if(!vis[j]) { sg[i] = j; break; } } }}int solve(int x){ int ret = 0; while(flag[x]){ ret ++; x /= flag[x]; } return ret + 1;}int main(){ SG(); make_prime(); while(~scanf("%d", &n)) { int ans = 0; for(int i = 0, x; i < n; i++) { scanf("%d", &x); int cnt = solve(x); ans ^= sg[cnt]; } puts(ans ? "Alice" : "Bob"); } return 0;}
阅读全文
1 0
- Acdream 1112 Alice and Bob(sg函数)
- ACdream 1112 Alice and Bob (SG函数)
- ACdream 1112 Alice and Bob (SG函数+线性素数筛)
- SG函数 Alice and Bob
- Alice and Bob (SG函数)
- ACdream群赛1112(Alice and Bob)
- ZOJ 3666 Alice and Bob(博弈 sg 函数入门)
- zoj 3666 Alice and Bob , SG函数
- Alice and Bob 题解 SG函数
- hdu 4111 Alice and Bob 博弈论 sg函数
- ACdream 1112 Alice and Bob (博弈&&素数筛选优化)
- ZOJ 3529 A Game Between Alice and Bob(博弈论-sg函数)
- hdu4111 Alice and Bob---sg dp记忆化求sg
- Alice and Bob(长春)
- SDUT2608(Alice and Bob)
- Alice and Bob(博弈)
- ZOJ Problem Set - 3666 Alice and Bob(SG)
- ZOJ 3666 Alice and Bob(博弈)
- 数组
- Easyui使用Dialog行内按钮布局
- 刷提报告002 洛谷P1008
- HUD 6033 Add More Zero(暑期训练1001)
- 多线程死锁问题
- ACdream 1112 Alice and Bob (SG函数)
- selenium XPath 定位
- Android性能优化之提高ListView性能的技巧
- 如何从NCBI下载SRA数据
- GDB调试基本命令
- AddressSanitizer算法及源码解析
- python核心高级学习总结4-------python实现进程通信
- 百练_4095:打字员
- C++Primer学习笔记(一):cin与cin.get()