日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

北邮OJ 1005. 16校赛-Hawei Learning C

發布時間:2024/9/30 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 北邮OJ 1005. 16校赛-Hawei Learning C 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

時間限制?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?(1T10), indicating the number of test cases.

For each test case, the first line contains one integers?N(1N100000), 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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。