Codeforces Beta Round #46 (Div. 2), problem: (D) Game 贪心YY
来源:互联网 发布:烈焰龙城轮回数据 编辑:程序博客网 时间:2024/05/17 02:27
题意:把一个二进制数改成01相间的状态。允许选择两个数字相同连块,随意改变它们的数字
做法:可以确定的是,不管什么样的数字都是可以改成01相间的样子的,而且长度相同的数字只有两种01相间的情况,而且有可能只有一种情况是可行的。而且又可以确定的是,只要是合理方案,其实就是一个一个找出不对的数字进行改变就可以了。YY YY YY。。
#include <iostream>#include <cstdio>#include <algorithm>const int LMT=1002;using namespace std;char s[LMT];int main(){ int n,a,b; a=b=0; scanf("%d",&n); scanf("%s",s); for(int i=0;i<n;i++) { if((s[i]+i)&1)a++; else b++; } printf("%d\n",min(a,b)); return 0;}
- Codeforces Beta Round #46 (Div. 2), problem: (D) Game 贪心YY
- Codeforces Beta Round #35 (Div. 2), problem: (D) Animals DP
- Codeforces Round #296 (Div. 2) - D. Clique Problem(贪心)
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] D. "Or" Game 贪心
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] D. "Or" Game (贪心法)
- Codeforces Beta Round #9 (Div. 2 Only), problem: (D) How many trees? DP
- Mysterious Present Codeforces Beta Round #4 (Div. 2 )problem D
- 【贪心】Codeforces Round #339 (Div. 2) D
- Codeforces Round #351 Div. 2 D 贪心
- Codeforces Round #303 (Div. 2) D 贪心
- Codeforces Round #378 (Div. 2) D 贪心
- Codeforces Round #320 (Div. 2) D. "Or" Game(贪心 前后缀)
- Codeforces Round #253 (Div. 2) D. Andrey and Problem (贪心+数学概率)
- 贪心(最大团)||dp+线段树(Codeforces Round #296 (Div. 2)D. Clique Problem)
- Codeforces Round #394 (Div. 2) D. Dasha and Very Difficult Problem 贪心
- Codeforces Round #394 (Div. 2)D. Dasha and Very Difficult Problem【贪心】
- Codeforces Round #394 (Div. 2) D. Dasha and Very Difficult Problem 贪心,二分
- Codeforces Round #412 ( Div. 2) D. Dynamic Problem Scoring(贪心)
- Linux服务器(redhat)的安全加固
- Axis WebService 一看就懂
- 多数据源的动态配置与加载使用兼框架交互的问题调试
- Java 按行读文件操作代码
- 设置TextView中文字的超链接
- Codeforces Beta Round #46 (Div. 2), problem: (D) Game 贪心YY
- XML文件生成
- 递归法实现全排列
- 有一个数组,每次从中间随机取一个,然后放回去,当所有的元素都被取过,返回总共的取的次数。写一个函数实现。复杂度是什么。
- log不知道打到哪里去了?
- 解决Spring TestContext下运行JUnit4抛错(java.lang.NoClassDefFoundError)的问题
- 工作第一天
- Oracle11g入门到精通摘要
- Pinyin4j