【POJ】3185-The Water Bowls 模拟
来源:互联网 发布:21端口打开 编辑:程序博客网 时间:2024/06/15 08:36
http://poj.org/problem?id=3185
将一列碗翻成口朝上,一把下去可能同时反转3个或2个(首尾),求最小翻转次数。
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;int a[21]={0};int f[21]={0};int ans=100;int tmp;int main(){ for (int i=1;i<=20;i++){ cin >> a[i]; } f[1]=tmp=1; for (int i=2;i<=20;i++){ //翻第一个 if (f[i]=(f[i-2]^f[i-1]^a[i-1])) tmp++; } if (tmp<ans&&(f[19]^f[20]^a[20])==0) ans=tmp; f[1]=tmp=0; for (int i=2;i<=20;i++){ //不翻第一个 if (f[i]=(f[i-2]^f[i-1]^a[i-1])) tmp++; } if (tmp<ans&&(f[19]^f[20]^a[20]==0)) ans=tmp; cout << ans << endl;}
阅读全文
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
- 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 (反转)
- 实验三
- 多条件查询语句,避免sql拼接引起sql注入写法
- 设计模式学习笔记之工厂模式
- Pytorch学习-CIFAR10分类
- bzoj 4565: [Haoi2016]字符合并
- 【POJ】3185-The Water Bowls 模拟
- 去掉table的默认样式 reset.css
- Python:类属性,实例属性,私有属性与静态方法,类方法,实例方法 属性分为实例属性与类属性 方法分为普通方法,类方法,静态方法 一:属性: 尽量把需要用户传入的属性作为实例属性,而
- MFC中判断IP地址输入框是否为空
- 常用的ssh,scp命令传文件
- Hadoop环境搭建之一安装jdk,hadoop基本配置及运行MapReduce案例在本地模式下
- Corn Fields
- DOCKER windows安装
- reset.css的一般写法