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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

Geek Challenge

發布時間:2023/12/16 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Geek Challenge 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Geek Challenge (dfs預處理)

Description
Geek Challenge [SKRZAT] is an old, old game from Poland that uses a game console with two buttons plus a joy stick. As is true to its name, the game communicates in binary, so that one button represents a zero and the other a one. Even more true to its name, the game chooses to communicate so that the base of the number system is minus two, not plus two, so we’ll call this representation “Weird Binary”. Thus the bit positions label the powers of minus two, as seen in the following five-bit tables:

Numbers are presented on the screen in Weird Binary, and then numbers are accepted in response from the console as a stream of zeroes and ones, terminated by a five-second pause.
You are writing a computer program to support the novice geek in playing the game by translating numbers between decimal and Weird Binary.
Input
The first line in the file gives the number of problems being posed without any white space.
Following are that many lines. Each line will either be a conversion into Weird Binary or out of Weird Binary: the letter “b” indicates that the rest of the line is written in Weird Binary and needs to be converted to decimal; the letter “d” indicates that the rest of the line is written in decimal and needs to be converted to Weird Binary.
The input data are in the range to fit within a 15-bit Weird Binary number, which represents the decimal number range –10922 to 21845, inclusive.
Output
For each conversion problem, show the type of problem, its input string, and the converted result in the format shown below, replicating even the spacing exactly as shown. Leading zeroes are not allowed.
Samples
Input
10
b 1001101
b 0111111
b 101001000100001
b 010010001000010
b 100110100110100
d -137
d 137
d 8191
d -10000
d 21000
Output
From binary: 1001101 is 61
From binary: 0111111 is -21
From binary: 101001000100001 is 19937
From binary: 010010001000010 is -7106
From binary: 100110100110100 is 15604
From decimal: -137 is 10001011
From decimal: 137 is 110011001
From decimal: 8191 is 110000000000011
From decimal: -10000 is 10100100110000
From decimal: 21000 is 101011000011000


思路:(sj啟迪)
①b操作很簡單;
②d操作,我們每一位進行暴力就好了,同map存一下(215)
注意前導零以及對0的操作


Code:

#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> PI; const int N = 2e4+10; const int mod = 100003; int T,x; string s; map<int,string> mp; void dfs(int c,int s,string x) {if(c>15) return;string t1,t2;int now;t1 = x + "0";t2 = x + "1";mp[s] = t1;dfs(c+1,s,t1);if((c+1)&1) s += pow(2,c);else s -= pow(2,c);mp[s] = t2;dfs(c+1,s,t2); } int main() {dfs(0,0,"");cin >> T;while(T--) {char op;cin >> op;if(op == 'b') {cin >> s;ll res = 0;int len = s.size();for(int i=0; i<len; i++) {ll tep = pow(2,len-i-1) * (s[i]-'0');if((i+1)&1) res += tep;else res -= tep;}cout<<"From binary: "<<s<<" is "<<res<<endl;} else {cin >> x;string tep = mp[x],res;reverse(tep.begin(),tep.end());int k = 0;while(tep[k]=='0') k++;tep.erase(tep.begin(),tep.begin()+k);if(!x) tep = "0";cout<<"From decimal: "<<x<<" is "<<tep<<endl;}}return 0; } /* 10 b 1001101 b 0111111 b 101001000100001 b 010010001000010 b 100110100110100 d -137 d 137 d 8191 d 0 d 21000 */

總結

以上是生活随笔為你收集整理的Geek Challenge的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 久久精品3 | 日韩久久免费视频 | 嫩草影院一区二区 | 欧美精产国品一二三 | 欧美色图在线播放 | 精品人伦一区二区三电影 | 国产丝袜美女 | av黄色免费 | 亚洲人一区 | 国产乱码精品一区二三赶尸艳谈 | 日本伦理一区 | 99国产在线播放 | 国产毛片在线 | 亚洲图片视频在线 | 日韩手机在线观看 | 成人在线影片 | 黄色av电影网址 | 日韩在线视频中文字幕 | 日韩中文字幕有码 | www.中文字幕av | 亚洲国产精品影院 | 欧美日韩色图 | 91蝌蚪九色| 无码国产精品一区二区高潮 | 欧美大波大乳巨大乳 | 久久男女| 亚洲福利久久 | 亚洲天堂高清 | 风韵少妇性饥渴推油按摩视频 | 国产夫妻性生活 | 日韩午夜一区 | av超碰在线观看 | 黄网在线免费 | 乌克兰黄色片 | 日韩综合精品 | 亚洲aaa视频 | 91视频成人免费 | 色婷婷综合久久久久中文一区二区 | 午夜精品无码一区二区三区 | 深夜视频在线免费 | 殴美一级片 | 成人午夜精品视频 | 亚洲精品国产精品国自产观看浪潮 | 我会温柔一点的日剧 | 国产精品搬运 | 两根大肉大捧一进一出好爽视频 | 日本黄色一区二区三区 | 激情国产在线 | 天堂中文在线网 | 日韩无码精品一区二区三区 | 伊人网在线| ,亚洲人成毛片在线播放 | 精射女上司| 精品久久精品久久 | 老色批av | 东京久久久 | 91网在线| 久久久亚洲精品视频 | 亚洲AV无码乱码国产精品牛牛 | 日韩人妻精品一区二区三区 | 国产精品毛片久久久 | 伊人焦久影院 | 偷拍视频一区 | 成人激情综合网 | 久久禁 | 国产精品suv一区二区69 | 亚洲骚图| 亚洲乱码国产乱码精品精软件 | 91免费视频国产 | 国产精品熟妇人妻g奶一区 a少妇 | 亚洲区 欧美区 | 探花精品 | 美女扒开腿让男人操 | 小妹色播 | 手机av网| 国产精品老熟女视频一区二区 | 成人黄色免费看 | 少妇特黄一区二区三区 | 亚洲热av | 国产天堂久久 | 亚洲第5页 | 婷婷色小说| 亚洲av毛片成人精品 | 91丝袜美女 | 亚洲一级淫片 | 男女日批免费视频 | 一本色道无码道dvd在线观看 | 久久久久99精品成人片 | 亚洲精品一区二区三区四区乱码 | 先锋影音在线 | 欧美人与动物xxxx | 国产一级片在线 | 人人舔| 嫩草天堂| 超碰超碰超碰超碰超碰 | 久久久久久久久久久久电影 | 五月激情丁香网 | 哈利波特3在线观看免费版英文版 | 免费视频www在线观看网站 |