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
for _ in xrange(int(raw_input())): | |
n, m = map(int, raw_input().split()) | |
if n > 2 and m > 2: | |
r = min(n, m) - 1 | |
if r % 2: | |
r -= 1 | |
m -= r | |
n -= r | |
if n is 1: | |
print 'R' |
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
from __future__ import division | |
for _ in xrange(int(raw_input())): | |
n = int(raw_input()) | |
out = 0 | |
for i in xrange(1, n + 1): | |
out += n / i | |
print '%.2f' % out |
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
def factor(x): | |
if x is 1: | |
return 1 | |
elif x is 3: | |
return 360 | |
else: | |
return 20 * factor(x - 1) | |
maya = {'S': 0, '.': 1, '-': 5} | |
n = int(raw_input()) | |
while n: |
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
from __future__ import division | |
from math import ceil | |
while True: | |
ing = map(int, raw_input().split()) | |
if ing[0] is -1: | |
break | |
m = int(ceil(max([ing[i] / ing[i + 4] for i in xrange(4)]))) | |
for i in xrange(4): | |
print m*ing[i + 4] - ing[i], | |
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
numbers = 3012501 * [True] | |
a = [0] | |
for i in xrange(1, 500001): | |
if a[-1] - i > 0 and numbers[a[-1] - i]: | |
a.append(a[-1] - i) | |
numbers[a[-2] - i] = False | |
else: | |
a.append(a[-1] + i) | |
numbers[a[-2] + i] = False | |
while True: |
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
while True: | |
n, d = map(int, raw_input().split()) | |
if n is 0: | |
break | |
else: | |
print n ** d |
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
for _ in xrange(int(raw_input())): | |
a, b, c = map(int, raw_input().split()) | |
print a**2 - 2*b |
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
for _ in xrange(int(raw_input())): | |
n = int(raw_input()) | |
print n - n/2 |
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
from math import pi, e, log | |
for _ in xrange(int(raw_input())): | |
n = int(raw_input()) | |
try: | |
print int(log(2*pi*n, 10)/2 + n * (log(n, 10) - log(e, 10))) + 1 | |
except ValueError: | |
print 1 |
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
#include <iostream> | |
#include <iomanip> | |
#include <vector> | |
#include <list> | |
#include <string.h> | |
#include <math.h> | |
using namespace std; | |
const int base = 1000000000; const int base_digits = 9; |