时间限制 1000 ms 内存限制 65536 KB

题目描述

Hawei is learning C programming language recently, but he is so naive that he mistakes the ∼ symbol in C for the ¬ symbol in mathemetics. In math calculation, the answer to ¬4 is the bitwise NOT of (100)2, ie., ¬(4)10=(011)2=(3)10. Thus, ¬4=3. But in C programming, the compiler will explain calculation ans=∼4 as the bitwise NOT of (00000000000000000000000000000100)2 because 4 is a 32-bit integer, ie., ans=∼(00000000000000000000000000000100)2=(11111111111111111111111111111011)2 =(−5)10.

Unaware of this slight difference, Hawei checked for the bug for a whole day. When he finally found it, he was so angry that he decided to define two new functions f(x) and G(x). Function f(x) returns the answer of ¬x, in other words, it is the bitwise NOT of xsince the most significant digit of x. For instance, we have: 
    f((4)10)=f((100)2)=(011)2=(3)10
    , and
    f((22)10)=f((10110)2)=(01001)2=(9)10

On the other hand, function G(x) is defined in following way:

输入格式

The input starts with a single line containing an integer T (1≤T≤10), indicating the number of test cases.

For each test case, the first line contains one integers N(1≤N≤100000), indicating the length of the string. The next lines contains a string S, representing the integer x of the corresponding test case in its binary form. It is guaranteed that there is no leading zeroes in the input.

输出格式

For each test case, output a single line containing a 01 string, indicating the answer of G(x) in binary form. No leading zeroes are allowed.

输入样例

1
3
100

输出样例

1

找规律,统计输入串中1的数量然后输出相应数量的1即可

#include<cstdio>
#define N 100050
using namespace std;
int main(){int t,n,i;char str[N];for(scanf("%d",&t);t--;){scanf("%d",&n);scanf("%s",str);for(i=0;str[i];i++){if(str[i]=='1'){printf("1");}}printf("\n");}return 0;
}

北邮OJ 1005. 16校赛-Hawei Learning C相关推荐

  1. 北邮OJ 1027. 16校赛-Archer in Archery

    时间限制 1000 ms 内存限制 65536 KB 题目描述 Archer(Emiya), also known as the red A, is famous for his talented s ...

  2. 北邮OJ 1022. 16校赛-Saber's Board

    时间限制 5000 ms 内存限制 65536 KB 题目描述 In a parallel universe, Saber has won the champion of every kind of ...

  3. 北邮OJ 1021. 16校赛-Stone Game

    时间限制 4000 ms 内存限制 65536 KB 题目描述 Alice and Bob are old friends in game theory. This afternoon they me ...

  4. 北邮OJ 1010. 16校赛-Binary Strings

    时间限制 5000 ms 内存限制 65536 KB 题目描述 One day, the teacher asked Weishen to judge whether a binary string ...

  5. 北邮OJ 981. 16校赛-Saber's Number Game

    时间限制 1000 ms 内存限制 65536 KB 题目描述 Saber is fond of number games of various kinds, she particularly lik ...

  6. 北邮OJ 980. 16校赛-R_clover's Challenge

    时间限制 2000 ms 内存限制 65536 KB 题目描述 R_clover wants to challenge Mengmengda_wsw's math,so he give her a f ...

  7. 北邮OJ 884. 16校赛-Average Modulo

    时间限制 5000 ms 内存限制 65536 KB 题目描述 We define function g on an array as: g([a0,a1,⋯,an−1])=(Σn−1l=0al) m ...

  8. 北邮oj题库刷题计划(更新ing)

    北邮oj题库刷题计划(更新ing) 83. A + B Problem 84 Single Number 85. Three Points On A Line 120 日期 121 最值问题 122 ...

  9. 北邮OJ 141 虚数

    北邮OJ 虚数 #include <bits/stdc++.h> using namespace std; typedef struct fushu{int x; //实部 int y; ...

最新文章

  1. 3.3 栈的链式存储结构
  2. Linux命令技巧之30个必会的命令技巧
  3. 基于子类的动态代理:
  4. Altair PollEx 2020中文版
  5. 错误 SQL TOP子句中的行数必须是整数
  6. StringUtils类中 isEmpty() 与 isBlank()的区别
  7. 游戏市场阴影下的手游厂商,和他们无法触碰的未来
  8. Unity内置的三套消息发送机制的应用实例
  9. Flex容器拖动(Bordercontainer为例)
  10. exchange 删除邮件
  11. 461. 汉明距离 golang
  12. cancase vector_基于Vector总线设备的CAN总线测试方法概述
  13. php中文切齿,PHP 各种函数
  14. 操作系统(2)-创建线程的几种方式
  15. signature=7a6addc49a87cb6a44a8da5a20a59d1f,Disks and Halos in Pre-Main-Sequence Stars
  16. Java加密算法库BouncyCastle
  17. word公式常用快捷键
  18. 京东官网首页js+css+html基础
  19. Unity打Android包报错Error building Player Exception OBSOLETE - Providing Android resources in AssetsPlug
  20. 墨菲定律 三种(is2120)

热门文章

  1. Learning to Learn:图神经网络上的元学习
  2. HDU 1715 大菲波数
  3. access 江苏计算机二级_你与计算机二级证书的距离就差这一篇推送了!
  4. Tomcat9URL不支持特殊字符解决方案
  5. 零基础带你快速入门consul-难道consul还能这样用?
  6. 《数据库系统实训》实验报告——事务的应用
  7. Element UI——布局容器el-container子元素强制上下排列
  8. 汇编语言——十六进制数据前加0规则
  9. postgreSQL的索引
  10. Bootstrap4+MySQL前后端综合实训-Day06-AM【eclipse详细配置Tomcat、开发web项目、servlet、连接MySQL8.0数据库、用户登录界面的编写与验证、分页查询】