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

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>
            亚洲午夜免费福利视频| 亚洲欧洲日本国产| 在线视频一区观看| 欧美一进一出视频| 久久综合伊人77777麻豆| 亚洲黄色免费| 亚洲天堂成人| 亚洲精品免费看| 久久综合九色九九| 久久永久免费| 欧美日韩三级一区二区| 久久久999国产| 欧美日韩亚洲高清| 久久国产精品久久久久久久久久| 最新亚洲一区| 亚洲综合色网站| 欧美韩日一区二区| 久久欧美肥婆一二区| 久久久久免费视频| 亚洲国产成人精品久久久国产成人一区| 久久夜色精品一区| 国产欧美一区二区三区沐欲| 国产欧美日韩在线播放| 久久综合色88| 国产伦精品一区二区三区四区免费| 欧美日韩伦理在线| 国产精品国产三级国产专播精品人 | 亚洲成人自拍视频| 性亚洲最疯狂xxxx高清| 国产欧美激情| 一区二区欧美在线| 欧美日本不卡高清| 久久久人成影片一区二区三区| 亚洲欧美成人精品| 在线成人免费观看| 欧美一级久久久| 亚洲一区二区三区免费观看 | 美女诱惑黄网站一区| 一本色道久久88亚洲综合88| 亚洲欧美中文日韩在线| 欧美日韩第一页| 欧美国产欧美亚州国产日韩mv天天看完整| 国产精品久久久999| 国产精品专区h在线观看| 香蕉久久精品日日躁夜夜躁| 久久久久久久久岛国免费| 欧美不卡视频一区| 亚洲欧美一区二区三区极速播放| 日韩香蕉视频| 国产精品丝袜久久久久久app| 欧美在线啊v一区| 亚洲欧洲在线一区| 久久久人成影片一区二区三区| 新67194成人永久网站| 羞羞答答国产精品www一本| 中文在线不卡视频| 久久成人免费视频| 新67194成人永久网站| 欧美三级视频在线播放| 国产精品www.| 欧美偷拍一区二区| 免费日韩av| 日韩视频在线观看一区二区| 日韩视频第一页| 亚洲啪啪91| 亚洲欧美日韩国产另类专区| 夜夜精品视频| 亚洲永久网站| 欧美在线免费视频| 国产人妖伪娘一区91| 欧美国产高清| 亚洲午夜国产成人av电影男同| 亚洲特级毛片| 性欧美video另类hd性玩具| 亚洲男人的天堂在线aⅴ视频| 欧美一区二区三区在线播放| 久久久中精品2020中文| 欧美不卡视频| 亚洲欧美日韩精品一区二区| 老司机67194精品线观看| 久久欧美中文字幕| 欧美性一区二区| 亚洲精品综合在线| 91久久久久| 欧美特黄一区| 亚洲一级在线观看| 亚洲一二三区在线| 国产乱子伦一区二区三区国色天香| 亚洲手机成人高清视频| 一本一本久久a久久精品综合麻豆| 欧美精品在线观看一区二区| 99国内精品久久| 一区二区欧美在线| 国产欧美欧美| 美女福利精品视频| 欧美xart系列高清| 一本大道av伊人久久综合| 亚洲裸体在线观看| 国产精品一区=区| 久久精品电影| 欧美电影在线播放| 亚洲欧美日韩天堂| 久久男女视频| 亚洲一级网站| 久久久久国产精品一区三寸| 一区二区三区欧美在线| 亚洲欧美日韩在线| 国产日韩在线一区| 久久av一区二区三区亚洲| 久久久久久婷| 99在线|亚洲一区二区| 这里只有精品视频| 亚洲国产精品成人综合色在线婷婷| 亚洲娇小video精品| 欧美色综合天天久久综合精品| 久久免费精品视频| 国产精品第三页| 免费看亚洲片| 国产欧美另类| 999在线观看精品免费不卡网站| 国产欧美综合在线| 欧美一区二区在线播放| 欧美日韩国语| 国产在线日韩| 亚洲精品一区中文| 亚洲日韩第九十九页| 久久综合九色综合欧美狠狠| 欧美一级日韩一级| 国产精品扒开腿做爽爽爽软件| 欧美成人亚洲成人| 在线观看视频亚洲| 久久久7777| 久久久久久亚洲精品不卡4k岛国| 国产精品久久久久一区二区三区共 | 欧美激情91| 在线成人欧美| 欧美专区第一页| 亚洲欧美久久久| 国产日韩精品一区二区浪潮av| 午夜欧美理论片| 欧美激情按摩| 国产欧美欧美| 欧美在线影院在线视频| 久久久女女女女999久久| 久久精品72免费观看| 久久久久久久久久久成人| 国产午夜久久久久| 久久野战av| 日韩亚洲欧美综合| 久久久精品一区二区三区| 亚洲国产免费看| 欧美在线一区二区| 亚洲视频中文字幕| 男人的天堂成人在线| 久久久国产精彩视频美女艺术照福利| 欧美在线视频不卡| av72成人在线| 久久精品国产一区二区三区| 99re6热在线精品视频播放速度| 欧美啪啪成人vr| av成人福利| 亚洲视频在线观看免费| 亚洲激情偷拍| 欧美中文字幕在线| 久久国内精品视频| 久久精品91久久香蕉加勒比| 久久成人羞羞网站| 精品成人国产在线观看男人呻吟| 一本色道久久综合亚洲精品小说| 1024国产精品| 国产欧美一区二区精品仙草咪 | 亚洲一级网站| 亚洲美女视频网| 亚洲精品国产精品久久清纯直播| 国产精品稀缺呦系列在线| 欧美无乱码久久久免费午夜一区| 欧美日韩一区精品| 国产精品久久久久秋霞鲁丝| 久久久精品日韩欧美| 中文欧美字幕免费| 日韩网站在线观看| 嫩草影视亚洲| 亚洲国产精品久久久久秋霞蜜臀 | 国产精品日韩欧美一区二区| 欧美 日韩 国产一区二区在线视频| 亚洲精品一区二区三区四区高清| 美日韩精品免费| 快播亚洲色图| 欧美日韩精品欧美日韩精品一| 欧美在线观看视频在线| 午夜久久tv| 亚洲第一在线综合在线| 国产亚洲精品成人av久久ww| 欧美日韩中文字幕日韩欧美| 国产三级欧美三级| 亚洲国产精品一区二区三区| 亚洲一区二区三区免费观看| 亚洲国内自拍| 亚洲午夜激情网站| 久久久久久自在自线|