poj1023
来源:互联网 发布:折弯机编程教学 编辑:程序博客网 时间:2024/06/06 18:31
参考http://blog.sina.com.cn/s/blog_8716ef750100wxxb.html
注意:要表示的数字的类型要用long long,在输入时用"%lld"
//Source Code//Problem: 1023 Memory: N/A Time: N/A //Language: C Result: Wrong Answer #include<stdio.h>#include<memory.h>#define LEN 65struct Funk{int k;char flag[LEN];//存储p-n串int used[LEN];//跟着记录哪些基数被使用};struct Funk funk;int main(){int testNum;int i,j;long long input;//需要表示的数字scanf("%d", &testNum);while(testNum--){memset(&funk,0,sizeof(struct Funk));j=0;scanf("%d", &funk.k);scanf("%s", funk.flag);scanf("%d", &input);for(i=funk.k-1; i>=0; i--){if(input%2 != 0)//input是奇数{if(funk.flag[i] == 'p')input = (input-1);else if(funk.flag[i] == 'n')input = (input+1);input /= 2;funk.used[j++] = 1;}else{input /= 2;funk.used[j++] = 0;}}if(input == 0){for(i=funk.k-1; i>=0; i--){printf("%d", funk.used[i]);}}elseprintf("Impossible");printf("\n");}return 0;}
- poj1023
- POJ1023
- poj1023
- poj1023
- poj1023
- poj1023
- poj1023 进制
- poj1023 二进制-十进制
- POJ1023解题报告
- poj1023 2010.2.22
- poj1023(分析)
- OJ-POJ1023-二进制处理
- POJ1023 The Fun Number System
- poj1023:The Fun Number System有趣的进制系统
- POJ1023 The Fun Number System【进制相关】
- Editplus FTP远程访问Ubuntu
- JAVA Metrics度量工具 - Metrics Core 翻译
- Hibernate课堂小结三 (级联操作)
- 设计模式20:中介者模式【行为型】
- VideoIO Flash-based audio and video communication
- poj1023
- 内存的工作原理及时序介绍
- tomcat 启动不起来
- 顺序栈的实现。。。。
- VideoIO Flash-based audio and video communication
- 一个Sqrt函数引发的血案
- Java乔晓松-Hibernate原理和应用2
- 程序员的20个常见瓶颈
- VideoIO Flash-based audio and video communication