HDU 5143 NPY and arithmetic progression 思维+枚举
来源:互联网 发布:更改防火墙端口 编辑:程序博客网 时间:2024/06/05 08:52
HDU 5143
题意:1,2,3,4的个数分别为a,b,c,d 问用这些数是否能组成若干个长度>=3的等差数列.
a,b,c,d<=1e9.
首先,AP(等差数列)只有6种,111(...),222(..),333(...),123,234,1234
关键点:3个123 可以看作3个1,3个2,3个3. 234,1234也类似.
题意:1,2,3,4的个数分别为a,b,c,d 问用这些数是否能组成若干个长度>=3的等差数列.
a,b,c,d<=1e9.
首先,AP(等差数列)只有6种,111(...),222(..),333(...),123,234,1234
关键点:3个123 可以看作3个1,3个2,3个3. 234,1234也类似.
所以最后结果只有 常数列+ 0~2个123,0~2个234,0~2个1234 27种情况 直接暴力枚举即可.
#include <bits/stdc++.h>using namespace std;typedef pair<int,int> ii;typedef long long ll;const int N=2e5+5;int a[5];bool check(int x,int y,int z){ int one=a[1]-(x+z); int two=a[2]-(x+y+z); int three=a[3]-(x+y+z); int four=a[4]-(y+z); return ((one>=3||one==0) && (two>=3||two==0)&& (three==0||three>=3)&&(four==0||four>=3));}int main(){ int T,n=4; cin>>T; while(T--) { bool flag=false; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=0;i<=2;i++) for(int j=0;j<=2;j++) for(int k=0;k<=2;k++) if(check(i,j,k)) flag=true; puts(flag?"Yes":"No"); } return 0;}
阅读全文
0 0
- HDU 5143 NPY and arithmetic progression 思维+枚举
- hdu 5143 NPY and arithmetic progression(枚举)
- HDU 5143 NPY and arithmetic progression(思维题)
- hdu 5143 NPY and arithmetic progression(思路,枚举)
- HDU 5143 NPY and arithmetic progression DFS
- hdu 5143 NPY and arithmetic progression
- HDU 5143 NPY and arithmetic progression
- hdu 5143 NPY and arithmetic progression
- HDU 5143 NPY and arithmetic progression DFS
- HDU 5143 NPY and arithmetic progression (枚举基本类型123、234、1234的个数)
- HDOJ 5143 NPY and arithmetic progression DFS
- HDOJ 5143 NPY and arithmetic progression
- 【CUGBACM15级BC第22场 B】hdu 5143 NPY and arithmetic progression
- HDU5143 NPY and arithmetic progression【暴力】
- HDU5142 NPY and arithmetic progression && BestCoder Round #23 1002
- ARITHMETIC PROGRESSION
- Arithmetic Progression
- Arithmetic Progression
- 不同BIOS下的U盘启动设置方法
- Matlab 的动态曲线绘图
- 基于VC 6.0 开发的MFC程序如何在文件资源管理器中浏览并选中操作文件
- Qt之右键弹出菜单
- Learnable pooling with Context Gating for video classification
- HDU 5143 NPY and arithmetic progression 思维+枚举
- 在结构体中内存对齐的规则及其重要性
- 机器学习——感知机与神经网络
- [转] 凸包求解算法
- 快速排序
- String
- 19、js三块、弹出框、open、close、定时器
- java开发 10.1/10.2/10.3
- Graph Theory NO.2 HDU_1272_小希的迷宫_并查集