HDU 2051 Bitset

来源:互联网 发布:淘宝运营正确思路流程 编辑:程序博客网 时间:2024/05/22 12:48

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2051


Bitset

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 13647    Accepted Submission(s): 10422


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
1
2
3
 

Sample Output
1
10
11

#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>#include<iostream>#include<algorithm>#include<sstream>#include<vector>#include<map>#include<stack>#include<list>#include<set>#include<queue>#define LL long long#define lson l,m,rt<<1#define rson m+1,r,rt<<1 | 1using namespace std;const int maxn=1005,maxe=100005,inf=1<<29;int n,m;void ToBin(){    int a[maxn],p=0;    while(n) a[p++]=n%2,n/=2;    while(p) printf("%d",a[--p]);    printf("\n");}int main(){    while(~scanf("%d",&n))    {        ToBin();    }    return 0;}

 

0 0
原创粉丝点击