hdu 4672 Present Day, Present Time(博弈)
来源:互联网 发布:淘宝试衣间在哪 编辑:程序博客网 时间:2024/06/07 02:04
题目链接:hdu 4672 Present Day, Present Time
解题思路
这题数据有点水。
代码
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 100005;const int maxm = 105;int N, M, T, dp[maxn], A[maxn], B[maxm];char name[2][maxm];void init () { scanf("%s%s", name[0], name[1]); for (int i = 1; i <= N; i++) scanf("%d", &A[i]); for (int i = 1; i <= M; i++) scanf("%d", &B[i]); sort(B + 1, B + 1 + M); T = B[M] * B[M]; memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int i = 1; i <= M; i++) { for (int j = 0; j + B[i] <= T; j++) { if (dp[j] == -1) continue; dp[j+B[i]] = max(dp[j+B[i]], dp[j] + 1); } }}int main () { while (scanf("%d%d", &N, &M) == 2) { init(); int ans = 0; for (int i = 1; i <= N; i++) { if (A[i] <= T) { if (dp[A[i]] == -1) {ans = 0; break; } else ans ^= dp[A[i]]; } else { int x = (A[i] - T) % B[1] + T - B[1]; if (dp[x] == -1) { ans = 0; break; } else ans ^= (dp[x] + (A[i]-x) / B[1]); } } ans = (ans ? 0 : 1); if (N == 1 && (A[i] > B[1])) ans = 0; printf("%s\n", name[ans]); } return 0;}
0 0
- hdu 4672 Present Day, Present Time(博弈)
- HDU 4672 Present Day, Present Time 博弈论
- Present()
- Present
- Present
- hdu(1563)Find your present!
- hdu 2095 find your present(2)
- HDU 2095 find your present
- hdu 1563 Find your present!
- hdu-1563 Find your present!
- hdu 1563 Find your present!
- HDU 4809 Cirno’s Present
- HDU 1563 Find your present!
- hdu-2095-find your present (2)//1563-find your present
- HDU 2095 Find your present (2) (位异或)
- HDU 2095 find your present (2) (水)
- hdu 2095 find your present (2)(位异或)
- hdu - 2095 - find your present (2)(异或)
- 适配器模式
- Codeforces Round #192 (Div. 1) C. Graph Reconstruction (随机化算法)
- Android源码分析-Alarm机制与Binder的交互
- 使用DrawImage函数进行拉伸绘制时出现的过度边沿现象
- 喜马拉雅听 手机端协议分析
- hdu 4672 Present Day, Present Time(博弈)
- 【MySQL】mysql中模糊查询的四种用法
- 使用oschina的git服务器图文流程
- hdu 4675 GCD of Sequence(计数)
- C++常见类型所占字节大小
- linux shell(2)
- 蓝懿ios 技术内容和心得交流分享 11.6
- Introduction to Algorithm - Summary of Chapter 7 - Quicksort
- iOS开发——高德地图调研之显示地图、定位与地理编码等