codeforces1552 D. Array Differentiation(思维+暴力)
D. Array Differentiation
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template <class T=int> T rd()
{T res=0;T fg=1;char ch=getchar();while(!isdigit(ch)) {if(ch=='-') fg=-1;ch=getchar();}while( isdigit(ch)) res=(res<<1)+(res<<3)+(ch^48),ch=getchar();return res*fg;
}
int n,a[20];
bool dfs(int u,int x,bool ok)
{if(u==n+1) return (x==0&&ok);return dfs(u+1,x-a[u],1)||dfs(u+1,x+a[u],1)||dfs(u+1,x,ok);
}
int main()
{int Tc=rd();while(Tc--){n=rd();for(int i=1;i<=n;i++) a[i]=rd();if(dfs(1,0,0))puts("YES");elseputs("NO");}return 0;
}
codeforces1552 D. Array Differentiation(思维+暴力)相关推荐
- 夯实基础项目工程之图论——Uncle Bogdan and Country Happiness,Graph Coloring,How Many Paths?,Array Differentiation
文章目录 做题情况项目报告 Uncle Bogdan and Country Happiness Graph Coloring How Many Paths? Array Differentiatio ...
- L. Ray in the tube(思维暴力)
L. Ray in the tube(思维&暴力) 思路:思维+暴力. 记:A,BA,BA,B的横坐标距离为xxx. 1.当xxx为奇数时,显然x=1x=1x=1包含所有奇数的情况. 2.当x ...
- 14行代码AC_Zero Array(思维)
立志用更少的代码做更高效的表达 You are given an array a1,a2,-,an.In one operation you can choose two elements ai an ...
- Codeforces 846 A Curriculum Vitae 思维 暴力
题目链接: http://codeforces.com/contest/846/problem/A 题目描述: 给你一个串, 你可以做删除操作, 要求结果串0不能在1的右边, 问最多可以剩几个数字 解 ...
- 【JavaSE_06】Java中的数组(array)-思维导图
思维导图看不清楚时: 1)可以将图片另存为图片,保存在本地来查看 : 2)右击在新标签中打开放大查看 (IE不支持,搜狗,360可以):
- CodeForces - 1168B Good Triple(思维+暴力)
题目链接:点击查看 题目大意:给出一个长度为n的01字符串,求所有满足条件的区间对数[l,r],使得在区间[l,r]内至少存在一组满足条件的答案,这里第二层的满足条件是指存在两个正整数个x和k,满足s ...
- 【ZOJ - 3872】Beauty of Array(思维,计算贡献,枚举)
题干: Edward has an array A with N integers. He defines the beauty of an array as the summation of all ...
- javaSE_06Java中的数组(array)-思维导图
思维导图看不清楚时: 1)可以将图片另存为图片,保存在本地来查看 : 2)右击在新标签中打开放大查看 (IE不支持,搜狗,360可以): 转载于:https://www.cnblogs.com/TCB ...
- codeforces 768 C. Jon Snow and his Favourite Number(思维+暴力)
题目链接:http://codeforces.com/contest/768/problem/C 题意:给出n个数,k个操作,和一个x,每次操作先排序然后对奇数位数进行xor x操作,最后问k次操作后 ...
最新文章
- Nature:原来益生菌是这么搞定致病菌的
- 处理Http请求Gzip格式响应
- 【部署】Nginx长连接配置
- [原创].如何解决Nios II SBTE中出现的undefined reference to `xxx'警告
- java1.8--改进的接口
- [转]Ubuntu以管理员权限打开文件(夹)
- C++组合数(combination)的实现
- 【ACL 2021】基于一致性正则的跨语言微调方法
- html______1
- 截流式合流制设计流量计算_截流式合流管道的设计流量.PPT
- 异常数据剔除---格拉布斯准则(java实现)
- 华为员工晒百万收入,网友:看来我对华为也有误解
- python装饰器底层原理讲解
- 在系统中自主实现全国行政区域结构化管理
- C++ vector内存分配机制
- 老毛桃安装U盘 格式化 不可删除的部分
- 第十一届蓝桥杯2020年C++A组省赛题解
- LPC1788在外部RAM调试总结
- win10系统 百度网盘登录显示网络异常怎么解决?
- sangerbox使用教程_用iTOL轻松绘制高颜值系统进化树
热门文章
- php多进程 写入文件_PHP多进程中使用file_put_contents安全吗?
- linux 全双工 wifi热点,Linux中的同时套接字读/写(“全双工”)(特别是aio)
- hbase shell远程连接_hbase与phoenix集成
- leetcode101. 对称二叉树(两种做法)
- C++ 学习之旅(3)——头文件Header
- linux多行变一列,多行转为一列
- 使用对偶表示重新实现Stack(lua程序设计21.7练习21.3题)
- 操作系统复习题+最终版
- kodi pvr 不能安装_「家庭影音串流」电视最强播放器KODI使用方法
- 函数传参string_JavaScript 高阶函数入门浅析