NOJ [1295] About Loop
来源:互联网 发布:风险矩阵法判断准则 编辑:程序博客网 时间:2024/06/06 13:57
- 问题描述
This day, Death Moon told a story like that:
One integer can be represented by a binary. For example:
And you put the leftest ‘1’ to the rightest, it will be:
Next loop it will be:
And then the loop is end.
So now give you a integer, you should print all of its loop in one line.
- 输入
- This problem contains several cases. Each case only contains one integer N (1 <= N <= 10000000000000000000).
- 输出
- For each case, you should print its whole loop in one line.数太大,所以得用__int64,坑爹的我wa了好久按题意例如81000 -> 0001 -> 0010 -> 0100也就是每次把最左边的数移到最右边,几位的数就有几个对应的数
#include<stdio.h>
#include<string.h>
int str[200];
int main()
{
__int64 n,m;
while(~scanf("%I64d",&n))
{
m=n;
int cnt=0,len,s,t;
while(m!=0)
{
cnt++;
m/=2;
}
printf("%I64d", n);
if(n==1|| n==0)
printf("\n");
else
printf(" ");
len=cnt-1;
t=len;
while(n!=0)
{
str[len--]=n%2;
n/=2;
}
s=len+1;
for(int i=0;i<cnt-1;i++)
{
str[t+1]=str[s];
t++;
s++;
__int64 temp=0;
for(int j=s;j<=t;j++)
if(str[j])
{
__int64 tt=1;
tt<<=(t-j);
temp+=tt;
}
printf("%I64d",temp );
if(i==cnt-2)
printf("\n");
else
printf(" ");
}
}
return 0;
}
- NOJ [1295] About Loop
- about gtk main loop
- All about Loop back Adapter
- Noj
- loop
- loop
- Loop
- loop
- Loop & Loop
- about:
- about
- About
- About
- About
- NOJ 176
- NOJ 175
- NOJ 179
- NOJ 141
- 一天一到算法题——乘积分析
- NOJ [1306] Divide The Apples
- 如何观看Netflix的美国另一个国家
- NOJ [1369] A Breaking Computer
- NOJ [1173] Birdlike Angry Pig
- NOJ [1295] About Loop
- NOJ [1289] Will TT Get Snacks?
- 悲剧!中小企业惨痛的外训经历!
- NOJ [1148] Creating Palindrome
- POJ Stars
- Nginx配置文件nginx.conf中文详解(总结)
- sp3
- POJ To the Max
- pdf在线转换成word官方免费版