-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
748c36b
commit 5f0b251
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//DATE: 14/10/2015 | ||
//Author: Ramjeet Saran | ||
//http://www.spoj.com/problems/DANGER/ | ||
|
||
# include <bits/stdc++.h> | ||
# include <cmath> | ||
# define gc getchar_unlocked | ||
# define pc putchar_unlocked | ||
# define RWTYPE long int | ||
|
||
using namespace std; | ||
|
||
RWTYPE fastwrite(RWTYPE inp) { | ||
RWTYPE a = (inp < 0) ? -inp : inp; | ||
char snum[20]; | ||
int i = 0; | ||
do | ||
{ | ||
snum[i++] = a % 10 + 48; | ||
a = a / 10; | ||
}while(a != 0); | ||
|
||
if(inp < 0) | ||
snum[i++] = '-'; | ||
i--; | ||
|
||
while(i >= 0) | ||
pc(snum[i--]); | ||
pc('\n'); | ||
} | ||
|
||
int main(){ | ||
string in; | ||
double n; | ||
int _log, ans; | ||
cin>>in; | ||
while(1){ | ||
if(in[0] == '0' && in[1] == '0' && in[3] == '0') | ||
break; | ||
n = (in[0] - '0') * 10 + (in[1] - '0'); | ||
n *= pow(10, in[3] - '0'); | ||
// cout<<n<<endl; | ||
_log = log2(n); | ||
//cout<<_log<<endl; | ||
ans = (n - (1 << _log)) * 2 + 1; | ||
cout<<ans<<endl; | ||
cin>>in; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,3 +83,4 @@ http://www.spoj.com/users/raj94/ | |
79) ABCDEF | ||
80) GLJIVE | ||
81) CPRMT | ||
82) DANGER |