Skip to content

Commit

Permalink
IN Danger walk
Browse files Browse the repository at this point in the history
  • Loading branch information
ramjeetsaran committed Oct 14, 2015
1 parent 748c36b commit 5f0b251
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
49 changes: 49 additions & 0 deletions DANGER.cpp
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;
}
}
1 change: 1 addition & 0 deletions Readme
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ http://www.spoj.com/users/raj94/
79) ABCDEF
80) GLJIVE
81) CPRMT
82) DANGER

0 comments on commit 5f0b251

Please sign in to comment.