The Fun Number System
来源:互联网 发布:如何提高物理成绩知乎 编辑:程序博客网 时间:2024/05/21 10:55
#include<iostream>#include<string>using namespace std;void init(string str,int fuhao[]){int i=0;for(;i<str.size();i++){if(str[str.size()-i-1]=='p')fuhao[i]=1;if(str[str.size()-i-1]=='n')fuhao[i]=-1;}}long long int cheng2(int n){long long i=1;while(n--){i=i*2;}return i;}void print(int num[],int l){for(int i=l-1;i>=0;i--)cout<<num[i];cout<<endl;}int main(){int thetimes;cin>>thetimes;while(thetimes--){int l;string str;long long int res;cin>>l>>str>>res;int result[100]={0};int fuhao[100]={0};init(str,fuhao);//long long all=0;for(int i=0;i<l;i++){if(res%2==0){result[i]=0;res=res/2;}else{result[i]=1;res=(res-fuhao[i])/2;}}if(res==0){print(result,l);}elsecout<<"Impossible"<<endl;}}
思考要更加严密,每个位置都可能是0,最好是由后向前进行判断,若为奇数,则为1,若为偶数,应为0
0 0
- The Fun Number System
- POJ1023 The Fun Number System
- 1023 The Fun Number System
- POJ 1023 The Fun Number System
- POJ_1023 The Fun Number System解题报告
- POJ 1023 The Fun Number System
- POJ 1023 : The Fun Number System - 二进制
- POJ 1023 The Fun Number System 笔记
- POJ 1023--The Fun Number System
- poj 1023 --The Fun Number System(分析题)
- G - The Fun Number System解题报告(贺奕凯)
- poj1023:The Fun Number System有趣的进制系统
- POJ 1023 The Fun Number System (递推)
- POJ1023 The Fun Number System【进制相关】
- poj 1023 The Fun Number System 整数的表示
- pku 1023 The Fun Number Syst
- 10077 - The Stern-Brocot Number System
- 110507 The Stern-Brocot Number System
- Jeecg-P3 1.0版本发布,JAVA插件开发框架
- 项目10-太乐了
- 第四周项目4:程序分析(1)
- iOS CocoaPods 私有库 steps and tips
- 多线程-1
- The Fun Number System
- 第四周实践项目2———太乐了
- windows Bat 批处理脚本 教程
- IOS获取当前经纬度 有时不调用代理方法
- HDU 5128
- J2EE --- Statement VS PreparedStatement
- netty:protobuf的编码器ProtobufVarint32LengthFieldPrepender()、解码器ProtobufVarint32FrameDecoder()
- android Bitmap(将视图转为bitmap对象)
- CGLIB介绍与原理