两个对于一个数切割 k 次,然后切割以后把这些值加起来,然后继续切割 k 次,问谁先没有办法切割。

对于第一个人,先枚举每种切割的情况,然后拿去给第二个人切割,如果第二个人怎么样都没办法切割出来,那么就是第一个人赢。如果第二个人有办法切割,在枚举第二个人所有可以切割的情况,给第一个人切割,如果第一个人没法切割,那么第二个人赢,如果第一个人还有办法切割,就继续循环下去。

#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lowbit(x) (x & (-x))
#define INOPEM freopen("in.txt", "r", stdin)
#define OUTOPEN freopen("out.txt", "w", stdout) typedef unsigned long long int ull;
typedef long long int ll;
const double pi = 4.0*atan(1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 2e6+;
const int maxm = ;
const int mod = 1e9+;
using namespace std; ll n, m;
int T, tol;
ll a[]; ll dfs(ll nn, ll sum, ll cnt) {
if(cnt < m- && nn == ) return ;
if(cnt == m-) {
if(dfs(nn + sum, , )) return ;
return ;
}
for(int i=; a[i]<=nn; i++) {
if(dfs(nn/a[i], sum+nn%a[i], cnt+)) return ;
}
return ;
} int main() {
a[] = ;
for(int i=; i<=; i++) a[i] = a[i-]*;
while(~scanf("%lld%lld", &n, &m)) {
int ans = dfs(n, , );
printf("%d\n", ans);
}
return ;
}

Number Cutting Game HDU - 2848(DFS)的更多相关文章

  1. F - JDG HDU - 2112 (最短路)&& E - IGNB HDU - 1242 (dfs)

    经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强.这时候,XHD夫妇也退居了二线,并在风景秀美的诸暨市浬 ...

  2. Tempter of the Bone HDU - 1010(dfs)

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  3. Leetcode之深度优先搜索(DFS)专题-1020. 飞地的数量(Number of Enclaves)

    Leetcode之深度优先搜索(DFS)专题-1020. 飞地的数量(Number of Enclaves) 深度优先搜索的解题详细介绍,点击 给出一个二维数组 A,每个单元格为 0(代表海)或 1( ...

  4. Leetcode之深度优先搜索(DFS)专题-200. 岛屿数量(Number of Islands)

    Leetcode之深度优先搜索(DFS)专题-200. 岛屿数量(Number of Islands) 深度优先搜索的解题详细介绍,点击 给定一个由 '1'(陆地)和 '0'(水)组成的的二维网格,计 ...

  5. HDU 2553 N皇后问题(dfs)

    N皇后问题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description 在 ...

  6. 深度优先搜索(DFS)和广度优先搜索(BFS)

    深度优先搜索(DFS) 广度优先搜索(BFS) 1.介绍 广度优先搜索(BFS)是图的另一种遍历方式,与DFS相对,是以广度优先进行搜索.简言之就是先访问图的顶点,然后广度优先访问其邻接点,然后再依次 ...

  7. D - 淡黄的长裙 HDU - 4221(贪心)

    D - 淡黄的长裙 HDU - 4221(贪心) James is almost mad! Currently, he was assigned a lot of works to do, so ma ...

  8. LeetCode Subsets II (DFS)

    题意: 给一个集合,有n个可能相同的元素,求出所有的子集(包括空集,但是不能重复). 思路: 看这个就差不多了.LEETCODE SUBSETS (DFS) class Solution { publ ...

  9. LeetCode Subsets (DFS)

    题意: 给一个集合,有n个互不相同的元素,求出所有的子集(包括空集,但是不能重复). 思路: DFS方法:由于集合中的元素是不可能出现相同的,所以不用解决相同的元素而导致重复统计. class Sol ...

随机推荐

  1. linux下编译upx ucl

    昨天,UPX发布了3.93版本. UPX(the Ultimate Packer for eXecutables)是一个非常全面的可执行文件压缩软件,支持dos/exe.dos/com.dos/sys ...

  2. [转帖]2015年时微软Win3.1崩溃迫使巴黎奥利机场短暂关闭

    https://www.ithome.com/html/it/188796.htm IT之家讯 2015年11月14日消息,上周法国巴黎奥利机场因为微软的Windows 3.1系统出现故障不得不迫使所 ...

  3. hdu2089_不要62

    不要62 题目大意:给你一个区间,算出该区间里不含62或4的数的个数 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2089 /* // 暴力就可以过了 ...

  4. Oracle pivot行转列函数案例

    with temp as( select '湖北省' province,'武汉市' city,'第一' ranking from dual union all select '湖北省' provinc ...

  5. Ubuntu18.04安装mysql5.7

    Ubuntu18.04安装mysql5.7 1.1安装 首先执行下面三条命令: # 安装mysql服务 sudo apt-get install mysql-server # 安装客户端 sudo a ...

  6. windows php7 安装redis扩展

    1,首先查看phpinfo 这会决定扩展文件版本(特别注意以php版本的architecture是x86还是64为准,不能以操作系统为准): 2.根据PHP版本号,编译器版本号和CPU架构  一定要根 ...

  7. memcach 命令行

    1. cmd上登录memcache # telnet 127.0.0.1 11211   2. 列出所有items stats items     3. 通过itemid获取key 接下来基于列出的i ...

  8. JavaScript之简易http接口测试工具网页版

    简易http接口测试工具网页版,支持get.post请求,支持json格式消息体,form表单暂不支持. httpClient.html <!DOCTYPE html> <html ...

  9. 转载 大话pcie

    原文https://blog.csdn.net/abcamus/article/details/76167747 一.PCIe DMA机制 PCIe控制器也提供DMA(Direct Memory ac ...

  10. Atcoder Beginner Contest 121 D - XOR World(区间异或和)

    题目链接:https://atcoder.jp/contests/abc121/tasks/abc121_d 题目很裸(Atcoder好像都比较裸 就给一个区间求异或和 n到1e12 肯定不能O(n) ...