DP 1015
来源:互联网 发布:android网络状态监听 编辑:程序博客网 时间:2024/05/24 06:55
Problem Description
Give you a number on base ten,you should output it on base two.(0 < n < 1000)
Input
For each case there is a postive number n on base ten, end of file.
Output
For each case output a number on base two.
Sample Input
123
Sample Output
11011
简单题意:10进制转2进制
解题思路:模拟转化过程
感想:不知道怎么用DP……
AC代码:
#include<iostream>using namespace std;const int N = 100;int a[N];int main(){int n;while(cin >> n){int i = 1;if(!n) cout << 0 ;while(n != 0){if(!(n % 2)) {a[i] = 0;i ++ ;}else {a[i] = 1;i ++ ;}n = n / 2;}for(int j = i - 1;j != 0;j --)cout << a[j] ;cout << endl;}}
0 0
- DP 1015
- DP<背包?> POJ 1015
- POJ 1015 DP
- poj 1015 dp
- poj 1015 DP
- POJ 1015 DP
- [DP] POJ 1015
- dp
- dp
- dp
- 【DP】
- dp
- dp
- DP
- DP
- DP
- DP
- DP
- Log4j的使用以及配置
- POJ 1006 Biorhythms
- poj 2398 (计算几何)
- 【HYSBZ 2301】——莫比乌斯反演
- 互补约数(GCD)续
- DP 1015
- Java之------单机版书店管理系统(设计思想和设计模式系列五)进货模块
- 【C语言】打印26字母金字塔
- JFrame中的setDfaultCloseOperation的含义
- location.hash详解
- js操作关闭子页面刷新父页面
- POJ 2081 Recaman's Sequence
- 趣学 C 语言(二)—— typedef 与 #define
- 网络编程之TCP/UDP及其流程比较