HDU 2700 Parity

奇偶校验

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <string.h>
 4 #define READ() freopen("in.txt", "r", stdin);
 5 using namespace std;
 6
 7 int main()
 8 {
 9     //READ()
10     char str[256];
11     while (gets(str))
12     {
13         if (str[0] == ‘#‘) break;
14         int len = strlen(str);
15         int one = 0, zero = 0;
16         for (int i = 0; i < len; i++)
17         {
18             if (str[i] == ‘0‘) zero++;
19             else if (str[i] == ‘1‘) one++;
20             else break;
21             putchar(str[i]);
22         }
23         if (str[len-1] == ‘e‘)
24         {
25             if (one % 2 == 0) puts("0");
26             else puts("1");
27         }
28         else
29         {
30             if (one % 2 == 0) puts("1");
31             else puts("0");
32         }
33     }
34     return 0;
35 }
时间: 2024-10-14 12:18:33

HDU 2700 Parity的相关文章

HDU 1517: kiki&#39;s game

/** * @link http://acm.hdu.edu.cn/showproblem.php?pid=1517 * @author Sycamore * @date Aug, 21 */// Suppose that their exists a direction(vertically or horizontally) in which// the steps remaining to arrive at the destination (n-1 or m-1) is even, as

HDU 5316 Magician(线段树区间合并, 子序列最值 多校2015啊)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5316 Problem Description Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an innate talent, gaining it through study and practice, or receiving it from an

HDU 5316 Magician(线段树区间合并入门)

本文纯属原创,转载请注明出处谢谢.http://blog.csdn.net/zip_fan. 题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5316 Time Limit: 18000/9000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Fantasy magicians usually gain their ability

图论 500题——主要为hdu/poj/zoj

转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i

HDU分类

模拟题, 枚举 1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 12

HDU 1058 Humble Numbers(离线打表)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1058 解题报告:输入一个n,输出第n个质因子只有2,3,5,7的数. 用了离线打表,因为n最大只有5842. 1 #include<stdio.h> 2 #define INT __int64 3 INT ans[5850] = { 4 0,1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,4

HDU 4833 Best Financing DP

Best Financing Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 120    Accepted Submission(s): 24 Problem Description 小 A想通过合理投资银行理财产品达到收益最大化.已知小A在未来一段时间中的收入情况,描述为两个长度为n的整数数组dates和earnings,表示在

HDU 4833 Best Financing (DP)

Best Financing Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 29    Accepted Submission(s): 3 Problem Description 小A想通过合理投资银行理财产品达到收益最大化.已知小A在未来一段时间中的收入情况,描述为两个长度为n的整数数组dates和earnings,表示在第dat

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116