This file contains hidden or 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 sqrt | |
| primes = [2] | |
| for i in xrange(3, 32000, 2): | |
| isPrime = True | |
| cap = sqrt(i) + 1 | |
| for j in primes: | |
| if j >= cap: | |
| break | |
| if not i%j: | |
| isPrime = False |
This file contains hidden or 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 log | |
| try: | |
| while True: | |
| a, b = map(int, raw_input().split('e')) | |
| n = a * 10**b | |
| p = 1 << int(log(n, 2)) | |
| ans = 1 + 2*(n - p) | |
| print ans | |
| except ValueError: | |
| pass |
This file contains hidden or 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
| ld = {'BC': [], 'CB': []} | |
| nd = {'CC': 0, 'BB': 0} | |
| for _ in xrange(int(raw_input())): | |
| s = raw_input() | |
| try: | |
| ld[s[0] + s[-1]].append(len(s)) | |
| except KeyError: | |
| nd[s[0] + s[-1]] += len(s) | |
| if len(ld['BC']) < len(ld['CB']): | |
| a = 'BC' |
This file contains hidden or 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
| save = out = int(raw_input()) | |
| flag = True | |
| for _ in xrange(9): | |
| out += int(raw_input()) | |
| if out < 100: | |
| save = out | |
| elif out is 100: | |
| print 100 | |
| flag = False | |
| break |
This file contains hidden or 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 = map(int, raw_input().split()) | |
| print a * b |
This file contains hidden or 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()) | |
| out = 0; f = 5 | |
| while n / f is not 0: | |
| out += n / f | |
| f = f * 5 | |
| print out |
This file contains hidden or 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; |
This file contains hidden or 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
| mod = 10**9 + 7 | |
| cache = {0: 1, 1: 1} | |
| def fibo(x): | |
| try: | |
| return cache[x] | |
| except KeyError: | |
| pass | |
| k = x / 2 | |
| if x % 2: | |
| cache[x] = (fibo(k) * (2*fibo(k-1) + fibo(k))) % mod |
This file contains hidden or 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 sqrt | |
| for _ in xrange(int(raw_input())): | |
| u, v, w, w1, v1, u1 = map(int, raw_input().split()) | |
| u2 = v**2 + w**2 - u1**2 | |
| v2 = w**2 + u**2 - v1**2 | |
| w2 = u**2 + v**2 - w1**2 | |
| vol = sqrt(4 * u**2 * v**2 * w**2 - u**2 * u2**2 - v**2 * v2**2 - w**2 * w2**2 + u2 * v2 * w2) / 12 | |
| print round(vol, 4) |
This file contains hidden or 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
| n = int(raw_input()) | |
| digits = '' | |
| if n is 0: | |
| digits = '0' | |
| else: | |
| while n: | |
| n, remainder = divmod(n, -2) | |
| if remainder < 0: | |
| n, remainder = n + 1, remainder + 2 | |
| digits = str(remainder) + digits |