青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

poj1023

The Fun Number System


Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 8549
Accepted: 2797

Description

In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight of the most significant bit (i.e., in position k-1), is -2^(k-1), and the weight of a bit in any position i (0 ≤ i < k-1) is 2^i. For example, a 3 bit number 101 is -2^2 + 0 + 2^0 = -3. A negatively weighted bit is called a negabit (such as the most significant bit in a 2's complement number), and a positively weighted bit is called a posibit.
A Fun number system is a positional binary number system, where each bit can be either a negabit, or a posibit. For example consider a 3-bit fun number system Fun3, where bits in positions 0, and 2 are posibits, and the bit in position 1 is a negabit. (110)Fun3 is evaluated as 2^2-2^1 + 0 = 3. Now you are going to have fun with the Fun number systems! You are given the description of a k-bit Fun number system Funk, and an integer N (possibly negative. You should determine the k bits of a representation of N in Funk, or report that it is not possible to represent the given N in the given Funk. For example, a representation of -1 in the Fun3 number system (defined above), is 011 (evaluated as 0 - 2^1 + 2^0), and
representing 6 in Fun3 is impossible.

Input

The first line of the input file contains a single integer t (1 ≤ t ≤ 10), the number of test cases, followed by the input data for each test case. Each test case is given in three consecutive lines. In the first line there is a positive integer k (1 ≤ k ≤ 64). In the second line of a test data there is a string of length k, composed only of letters n, and p, describing the Fun number system for that test data, where each n (p) indicates that the bit in that position is a negabit (posibit).
The third line of each test data contains an integer N (-2^63 ≤ N < 2^63), the number to be represented in the Funk number
system by your program.

Output

For each test data, you should print one line containing either a k-bit string representing the given number N in the Funk number system, or the word Impossible, when it is impossible to represent the given number.

Sample Input

2 3 pnp 6 4 ppnn 10

Sample Output

Impossible 1110

Source

Tehran 2002, First Iran Nationwide Internet Programming Contest


是個好題,不過沒想出來怎么做,跟數的補碼有關

code
#include <cstdio>
#include 
<cstdlib>
#include 
<cstring>
#include 
<cmath>
#include 
<ctime>
#include 
<cassert>
#include 
<iostream>
#include 
<sstream>
#include 
<fstream>
#include 
<map>
#include 
<set>
#include 
<vector>
#include 
<queue>
#include 
<algorithm>
#include 
<iomanip>
using namespace std;
__int64 maxnum,minnum;
__int64 n;
char s[100];
int main()
{
    
char str[100];
    
int t,len;
    
long long flag;
    scanf(
"%d",&t);
    
while(t--)
    {
        scanf(
"%d",&len);
        scanf(
"%s",str);
        scanf(
"%I64d",&n);
        maxnum
=0;
        minnum
=0;
        
for(int i=0; i<len; i++)
        {
            
if(str[i]=='p') maxnum=maxnum*2+1,minnum=minnum*2;
            
else maxnum=maxnum*2,minnum=minnum*2-1;
        }
        memset(s,
0,sizeof(s));
        
if((n<minnum&&minnum<=0)||(n>maxnum&&maxnum>=0)) printf("Impossible\n");
        
else
        {
            
for(int i=len-1; i>=0; i--)
            {
                flag
=0;
                
if(n&1)
                {
                    s[i]
='1';
                    
if(str[i]=='n')flag=1;
                }
                
else s[i]='0';
                n
=n>>1;
               
// printf("%d\n",n);
                if(flag) n++;
               
// printf("%d\n",n);
            }
            puts(s);
        }
    }
    
return 0;
}

posted on 2012-07-30 21:44 jh818012 閱讀(116) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

導航

統計

常用鏈接

留言簿

文章檔案(85)

搜索

最新評論

  • 1.?re: poj1426
  • 我嚓,,輝哥,,居然搜到你的題解了
  • --season
  • 2.?re: poj3083
  • @王私江
    (8+i)&3 相當于是 取余3的意思 因為 3 的 二進制是 000011 和(8+i)
  • --游客
  • 3.?re: poj3414[未登錄]
  • @王私江
    0ms
  • --jh818012
  • 4.?re: poj3414
  • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
  • --王私江
  • 5.?re: poj1426
  • 評論內容較長,點擊標題查看
  • --王私江
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            一本大道av伊人久久综合| 亚洲一区二区三区精品在线观看 | 一本色道88久久加勒比精品| 国产在线精品一区二区夜色| 国内自拍视频一区二区三区| 激情欧美一区二区| 最新日韩在线视频| 亚洲一区二区3| 久久综合国产精品| 亚洲国产另类 国产精品国产免费| 狼人天天伊人久久| 亚洲人成欧美中文字幕| 亚洲视频欧洲视频| 久久精品国产清自在天天线 | 国产精品亚洲а∨天堂免在线| 国产精品亚洲一区| 在线国产精品播放| 在线亚洲伦理| 久久久久久久一区二区| 亚洲精品1区2区| 午夜久久tv| 欧美看片网站| 国模叶桐国产精品一区| 日韩一区二区福利| 美日韩在线观看| 亚洲综合色激情五月| 欧美ab在线视频| 国内精品一区二区| 亚洲欧美日韩精品久久| 欧美国产精品久久| 午夜精品久久久久99热蜜桃导演| 欧美成人免费大片| 伊人久久综合97精品| 亚洲欧美在线磁力| 亚洲国产精品久久久久婷婷老年| 午夜精品视频| 欧美手机在线| av不卡在线看| 欧美freesex交免费视频| 亚洲欧美一区二区三区久久| 欧美日韩中文字幕在线| 日韩视频国产视频| 亚洲福利国产| 麻豆freexxxx性91精品| 狠狠综合久久| 久久精品人人| 欧美亚洲视频一区二区| 国产精品免费一区豆花| 一本久久精品一区二区| 亚洲成人在线免费| 久久影音先锋| 一本大道久久精品懂色aⅴ| 久久久久在线观看| 国产午夜精品一区二区三区欧美| 在线视频精品一区| 91久久国产综合久久| 美国十次了思思久久精品导航| 黄色成人免费观看| 久久先锋影音av| 久久久久久久尹人综合网亚洲| 国产一区二区久久久| 欧美专区18| 久久不见久久见免费视频1| 国产日韩欧美在线一区| 久久国产精品毛片| 欧美专区中文字幕| 激情久久综艺| 亚洲福利视频三区| 欧美日本国产精品| 亚洲综合社区| 欧美中文字幕在线视频| 狠狠色丁香久久婷婷综合丁香| 久久久久国色av免费看影院| 久久精品国产清高在天天线| ●精品国产综合乱码久久久久| 欧美大片一区| 欧美视频网址| 久久国产精品免费一区| 久久久夜色精品亚洲| 亚洲精品一区二区三区不| 日韩亚洲欧美中文三级| 国产精品综合色区在线观看| 美女性感视频久久久| 欧美成人第一页| 亚洲一区二区三区高清不卡| 久久av在线| 99国产精品视频免费观看| 亚洲图中文字幕| 在线精品亚洲一区二区| 日韩视频免费| 一区二区三区在线观看欧美| 亚洲国产一区二区三区a毛片| 国产精品久久久久久久久久免费| 久久久噜噜噜久噜久久| 欧美激情1区2区3区| 欧美一区三区二区在线观看| 老巨人导航500精品| 午夜日韩av| 嫩草影视亚洲| 久久精品视频一| 欧美日韩中文在线观看| 麻豆视频一区二区| 国产精品夜夜嗨| 亚洲人成在线观看一区二区| 狠狠色狠狠色综合日日91app| 妖精成人www高清在线观看| 一区久久精品| 亚洲欧美日韩综合国产aⅴ| 亚洲精品美女久久久久| 欧美在线亚洲| 午夜精品久久久久久久99樱桃| 国产午夜精品全部视频播放| 精品粉嫩aⅴ一区二区三区四区| 亚洲日本中文| 国内久久视频| 亚洲一区二区三区精品视频| 亚洲国产日韩美| 久久成人精品一区二区三区| 亚洲免费视频观看| 欧美绝品在线观看成人午夜影视| 久久综合图片| 国产综合久久| 午夜精品久久久| 欧美一级电影久久| 国产精品大片wwwwww| 日韩视频专区| 一区二区三区 在线观看视| 欧美国产综合| 最新中文字幕亚洲| 99re成人精品视频| 欧美激情久久久| 亚洲经典视频在线观看| 91久久黄色| 欧美激情精品久久久久久大尺度 | 亚洲激情电影中文字幕| 久久精品夜色噜噜亚洲a∨| 久久激情视频| 伊人久久大香线蕉综合热线| 久久精品国产久精国产一老狼| 久久精品国产久精国产思思| 国产视频欧美视频| 久久精品日产第一区二区| 久久在线视频| 亚洲欧洲日产国产网站| 欧美国产91| 99这里有精品| 欧美自拍偷拍午夜视频| 国产一区日韩一区| 另类天堂视频在线观看| 最新亚洲视频| 羞羞视频在线观看欧美| 国产综合色产在线精品| 另类激情亚洲| 在线视频欧美日韩| 久久久女女女女999久久| 亚洲国产另类 国产精品国产免费| 欧美ed2k| 亚洲主播在线播放| 久久一区免费| 日韩午夜激情| 国产精品丝袜xxxxxxx| 久久久久久亚洲精品杨幂换脸| 欧美国产激情| 亚洲欧美日韩精品久久久久| 狠狠综合久久av一区二区小说| 欧美高清成人| 亚洲欧美激情诱惑| 欧美国产国产综合| 午夜一级久久| 亚洲国产精品尤物yw在线观看| 久久综合色播五月| 欧美专区在线| 亚洲第一成人在线| 欧美激情一区二区三区四区| 国产午夜亚洲精品不卡| 亚洲精品一区二区三| 欧美一区二区三区啪啪| 樱花yy私人影院亚洲| 欧美日韩理论| 久久免费黄色| 亚洲图片在区色| 欧美黄色免费| 欧美影视一区| 一区二区三区免费在线观看| 国产一区二区三区视频在线观看| 欧美精品久久天天躁| 欧美一区二区在线观看| 99精品国产一区二区青青牛奶| 久久人人精品| 亚洲直播在线一区| 亚洲精品日韩欧美| 国产精品99久久久久久久女警| 国产精品福利在线观看| 免费不卡在线视频| 欧美亚洲综合久久| 99视频在线精品国自产拍免费观看| 麻豆精品在线视频| 久久精品欧美| 午夜欧美电影在线观看| 中文亚洲免费|