-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloj1042.cpp
61 lines (51 loc) · 1 KB
/
loj1042.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using namespace std;
#include<iostream>
#include<cmath>
#include<cstdio>
int main()
{
long long int num,arr[500],Case=1,T,temp,flag,k,i,temp2;
cin>>T;
while(T--)
{
scanf("%lld",&num);
temp=num;
k=flag=0;
int sss=-1,ttt=-1;
while(temp)
{
arr[k]=temp%2;
if(sss!=-1&&arr[k]==1)
{
xd=temp/2;
if(xd)
ttt=k;
}
if(arr[k]==0)
sss=k;
k++;
temp/=2;
}
if(ttt==-1&&sss==-1)
{
num=num-pow(2,k-1)+pow(2,k);
}
else if(ttt==-1)
{
}
/*if(ttt>sss)
{
num=num+pow(2,ttt)-pow(2,sss);
}
else if(arr[k-1]==1&&arr[k-2]==0)
{
num=pow(2,k);
}
else
{
num=num+pow(2,k)-pow(2,k-1);
}*/
printf("Case %lld: %lld\n",Case++,num);
}
return 0;
}