http://acm.hdu.edu.cn/showproblem.php?pid=2700

题目意思很重要;  //e:是要使字符串中1的个数变成偶数。o:是要使字符串中1的个数变成奇数

Parity

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1855    Accepted Submission(s): 1447

Problem Description
A bit string has odd parity if the number of 1's is odd. A bit string has even parity if the number of 1's is even.Zero is considered to be an even number, so a bit string with no 1's has even parity. Note that the number of 0's does not affect the parity of a bit string.
 
Input
The input consists of one or more strings, each on a line by itself, followed by a line containing only "#" that signals the end of the input. Each string contains 1–31 bits followed by either a lowercase letter 'e' or a lowercase letter 'o'.
 
Output
Each line of output must look just like the corresponding line of input, except that the letter at the end is replaced by the correct bit so that the entire bit string has even parity (if the letter was 'e') or odd parity (if the letter was 'o').
 
Sample Input
101e
010010o
1e
000e
110100101o
#
 
Sample Output
1010
0100101
11
0000
1101001010
 
Source
 
Recommend
zty
 //e:是要使字符串中1的个数变成偶数。o:是要使字符串中1的个数变成奇数。
#include<stdio.h>
#include<string.h>
int main()
{
int i,l,r;
char str[];
while(~scanf("%s",str)&&str[]!='#')
{
r=;
l=strlen(str);
for(i=;str[i]!=;i++)
{
if(str[i]=='')
r++;
}
for(i=;i<l-;i++)
printf("%c",str[i]);
if(str[l-]=='e')
{
if(r%==)
printf("");
else
printf("");
}
if(str[l-]=='o')
if(r%!=)
printf("");
else
printf("");
printf("\n");
}
return ;
}

HDU-2700 Parity的更多相关文章

  1. HDOJ/HDU 2700 Parity(奇偶判断~)

    Problem Description A bit string has odd parity if the number of 1's is odd. A bit string has even p ...

  2. HDU 2700 Parity(字符串,奇偶性)

    Parity Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  3. HDU 2700

    Parity Time Limit: 2000/1000 MS(Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  4. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  5. 类似区间计数的种类并查集两题--HDU 3038 & POJ 1733

    1.POJ 1733 Parity game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5744   Accepted: ...

  6. 【转载】图论 500题——主要为hdu/poj/zoj

    转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...

  7. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  8. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  9. HDU 1043 八数码问题的多种解法

    一.思路很简单,搜索.对于每一种状态,利用康托展开编码成一个整数.于是,状态就可以记忆了. 二.在搜索之前,可以先做个优化,对于逆序数为奇数的序列,一定无解. 三.搜索方法有很多. 1.最普通的:深搜 ...

随机推荐

  1. PHP学习笔记(八)

    关于PHP中的缓存函数ob_start() and ob_end_flush(). PHP输出机制:输出内容->缓存->输出到浏览器.ob_start(callback function) ...

  2. 02_Jquery_03_类选择器

    [简述] 类选择器就是通过类名(css类名)来查询元素! $(".myClass")就可以把所有包含了class="myClass"的元素查询出来 [index ...

  3. ZOJ 1013 Great Equipment(DP)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=13 题目大意:说的是有三种不同的装备,分别是头盔,盔甲,战靴需要运输, ...

  4. std::map的操作:插入、修改、删除和遍历

    using namespace std; std::map<int,int> m_map; 1.添加 for(int i=0;i<10;i++) { m_map.insert(mak ...

  5. HDU 5351 MZL's Border (规律,大数)

    [HDU 5351 MZL's Border]题意 定义字符串$f_1=b,f_2=a,f_i=f_{i-1}f_{i-2}$. 对$f_n$的长度为$m$的前缀$s$, 求最大的$k$满足$s[1] ...

  6. mysql数据库导出时报错mysqldump: Got error: 145的解决方法

      在给mysql数据库备份时,报错:mysqldump: Got error: 145: Table './jxzhtopenfire/ofoffline' is marked as crashed ...

  7. VI一个终端编辑多个文件的命令

      可分两种情况: 在不同窗口中打开多个文件:   如果已经打开一个了一个文件, 则在vi的命令输入状态下输入 :sp 另外一个文件的路径及文件名, 如此就可以在一个窗口打开多个文件了.   可以使用 ...

  8. CentOs install oracle instant client

    rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm rpm -ivh oracle-instantclient11.2-de ...

  9. eclipse汉化安装

    http://hi.baidu.com/rankabc/item/b07e03466550e4ce1381dac4 Eclipse汉化方法 网上搜了很多教程,步骤都不够详细,因此写一篇傻瓜版教程让新手 ...

  10. hdu 1009 贪心算法

    博主英语不好,看懂个大概,老鼠有M磅猫食.有N个房间,每个房间前有一只猫,房间里有老鼠最喜欢的食品JavaBean,J[i].若要引开猫,必须付出相应的猫食F[i]. 当然这只老鼠没必要每次都付出所有 ...