杭电ACM 1196

#include<stdio.h>
int main()
{
int num,j,k,s,f;
int a[7]={0,0,0,0,0,0,0};
while(scanf("%d",&num)!=EOF){
if(num==0)
break;
if(num==1)
printf("1\n");
else
{j=6;
k=0;
for(int i=1;i<=6;i++)
{
a[j]=num%2;
num=num/2;
if(num==1)
{
a[j-1]=1;
k=1;}
j--;
if(k==1)
break;
}
for(int i=6;i>=0;i--)
{
if(a[i]==1)
{
f=6-i;
if(f==0)
{
s=1;
break;
}
else
s=1;
for(int p=1;p<=f;p++)
s=s*2;
break;
}
}
printf("%d\n",s);
}
}
return 0;
}

时间: 2024-08-19 11:05:23

杭电ACM 1196的相关文章

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

杭电ACM题目分类

杭电ACM题目分类 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028. 1029.1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092. 1093.1094.1095.1096.1097.1098.1106.1108.1157.1163.1164.1170.1194.1196. 1197.1201.1202.1205.1219.1234.123

杭电ACM Java实现样例

若使用Java求解杭电ACM,答案提交必须注意两点: 1.类名一定得是Main,否则服务器无法编译: 2.必须用while进行输入判断. 以1000题测试题为例,代码如下: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan=new Scanner(System.in); while(scan.hasNextInt()) { int a=scan.n

杭电ACM水仙花数

水仙花数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 96473    Accepted Submission(s): 28632 Problem Description 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的: "水仙花数"是指一个三位数,它的各位数字的立方和等于其本身,比如:1

杭电 acm 2053 ( Switch Game )

这题思路: 一开始有n盏灯,且全部为关闭状态,都记为 0  就是  The initial condition :      0 0 0 0 0 … 然后之后进行i操作就是对这些灯以是否能被i整除,进行改变状态,如将 0 改为 1 或 将 1 改为 0 正如提醒里的 After the first operation :  1 1 1 1 1 … After the second operation : 1 0 1 0 1 … After the third operation :  1 0 0

杭电acm 1034题

Problem Description A number of students sit in a circle facing their teacher in the center. Each student initially has an even number of pieces of candy. When the teacher blows a whistle, each student simultaneously gives half of his or her candy to

杭电acm 2095 find your present (2)

#include<iostream>using namespace std;int main(){    int n,x,y;    while(cin>>n,n)    {         cin>>x;                   while(--n)         {             cin>>y;             x=x^y;         }         cout<<x<<"\n&q

杭电ACM 2046 阿牛的EOF牛肉串

我用到了两个数组,d1[n]表示长度为n的牛肉串最后一个字符不是'O',d2[n]表示长度为n的牛肉串最后一个字符是'O'.这样结果就是d1[n]+d2[n]:对于已经得到了长度为n-1的牛肉串,我们可以来讨论在第n个位置放置何种字符的牛肉串. 已得到第n-1个位置的字符 第n个位置需要放置的字符 结果 不是'O' 不是'O' 得到长度为n的,结尾不是'O'的字符串 不是'O' 是'O' 得到长度为n的,结尾是'O'的字符串 是'O' 不是'O' 得到长度为n的,结尾不是'O'的字符串 是'O'

杭电acm 1049题

一道水题..... 大意是一条1inch的虫子在一个n inch的盒子的底部,有足够的能够每一分钟往上爬u inch,但是需要休息一分钟,这期间会往下掉d inch,虫子爬到盒子口即认为结束.要求计算出给定的n,u,d虫子爬上的时间. 1 /****************************************************** 2 杭电acm 1049题 已AC 3 *****************************************************/