poj-3185 The Water Bowls
来源:互联网 发布:JavaScript什么是闭包 编辑:程序博客网 时间:2024/04/30 09:18
题意: 将一列碗翻成口朝上,一把下去可能同时反转3个或2个(首尾),求最小翻转次数。
感觉好奇葩的一个题目.....
我不知道怎么求最小值啊。。。
后来看了看别人的思路....
感觉好奇葩的一个题目.....
我不知道怎么求最小值啊。。。
后来看了看别人的思路....
发现枚举首元(翻转情况),当首元确定了。后面的就都确定了。。。。。。。
#include <iostream>#include <map>#include <algorithm>#include <cstdio>#include <cstring>#include <cstdlib>#include <vector>#include <queue>#include <stack>#include <functional>#include <set>#include<sstream>#include <cmath>using namespace std;#define pb push_back#define PB pop_back#define bk back()#define fs first#define se second#define INF 1e9*2+10#define sq(x) (x)*(x)#define eps (1e-7)#define clr(x) memset((x),0,sizeof (x))#define cp(a,b) memcpy((a),(b),sizeof (b))int a[25];int f[25];int dic[3][2]={-1,0,0,0,1,0};int calc(int s){ clr(f); int res=s; if(s) f[1]=1; for(int i=1;i<=19;i++) { if((a[i]+f[i]+f[i-1])&1) { res++; f[i+1]=1; } } if((a[20]+f[20])&1) return INF; return res;}int main(){ for(int i=1;i<=20;i++) scanf("%d",&a[i]); printf("%d\n",min(calc(0),calc(1))); return 0;}
0 0
- poj 3185 The Water Bowls
- POJ 3185 (The Water Bowls)
- POJ 3185 The Water Bowls
- poj 3185 The Water Bowls
- POJ 3185 The Water Bowls
- POJ 3185 The Water Bowls
- POJ-3185-The Water Bowls
- poj-3185 The Water Bowls
- The Water Bowls POJ 3185
- poj 3185 The Water Bowls 高斯消元
- poj -- 3185 The Water Bowls(高斯消元)
- poj 3185 The Water Bowls(高斯消元)
- poj 3185 The Water Bowls(高斯消元)
- POJ 3185 The Water Bowls(高斯消元)
- poj 3185 The Water Bowls (高斯消元)
- POJ 3185 The Water Bowls(高斯消元)
- POJ - 3185 The Water Bowls (反转)
- POJ 3185 The Water Bowls (高斯消元)
- js表单验证
- UGUI ScrollRect滚动优化:无限循环利用Item
- 开放-封闭原则
- html知识复习
- ubuntu12.04 下安装配置samba
- poj-3185 The Water Bowls
- Mysql 里CHAR和VARCHAR的最大长度及一些注意事项
- 整数变换问题和N皇后问题解析(C语言)
- 七、Linux/UNIX操作命令积累【touch、chkconfig】
- getopt:命令行选项、参数处理
- POJ-3276 Face The Right Way
- android常见的库文件
- git学习推荐
- Angularjs1.x 中的 constant, value