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
| import sys | |
| gabage = raw_input() | |
| i = 1 | |
| for line in sys.stdin: | |
| (n, k) = map(int, line.split()) | |
| if(k % (2 ** n) == 2 ** n - 1): | |
| print("Case #%d: ON" % i) | |
| else: | |
| print("Case #%d: OFF" % i) |
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
| import random | |
| def leaf(a): | |
| prob = random.randint(1,100) | |
| #print prob | |
| if prob == 1: | |
| a[0] = 0.0 | |
| a[1] = 0.16 * a[1] | |
| elif 1 < prob and prob <= 85: | |
| a[0] = 0.85 * a[0] + 0.04 * a[1] |
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
| a = {i * 3 for i in range(1000) if i * 3 < 1000} | |
| b = {i * 5 for i in range(1000) if i * 5 < 1000} | |
| print(sum(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
| a = [1, 2] | |
| b = 0 | |
| while True: | |
| b = a[-1] + a[-2] | |
| if b > 4000000: | |
| break | |
| a.append(b) | |
| c = [i for i in a if i % 2 == 0] | |
| print(sum(c)) |
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
| #Sieve of Eratosthenes | |
| #Find primes under n | |
| def sieve(n): | |
| primes = [] | |
| table = [0 for i in range(n+1)] | |
| for i in range(2, n+1): | |
| if table[i] == 0: | |
| primes.append(i) | |
| j = 2 |
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
| def fact(n): | |
| primes = [] | |
| i = 2 | |
| tmp = n | |
| while tmp != 1: | |
| if i > n ** 0.5: | |
| primes.append(i) | |
| break | |
| if tmp % i == 0: |
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
| #project euler problem 4 | |
| #auther @iizukak | |
| def isPalindrome(s): | |
| for i in range(len(s) / 2): | |
| if s[i] != s[- (i + 1)]: | |
| return False | |
| return True | |
| def findPalindrome(): |
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
| #project euler problem 5 | |
| #auther @iizukak | |
| #Greatest Common Divisor | |
| def gcd(a, b): | |
| if b == 0: | |
| return a | |
| else: | |
| return gcd(b, 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
| #project euler problem 6 | |
| #auther @iizukak | |
| def powdiff(n): | |
| i = 0 | |
| j = 0 | |
| for k in range(1, n + 1): | |
| i = i + k ** 2 | |
| for k in range(1, n + 1): | |
| j = j + k |
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
| #project euler problem 7 | |
| #auther @iizukak | |
| def sieve(n): | |
| primes = [] | |
| table = [0 for i in range(n+1)] | |
| for i in range(2, n+1): | |
| if table[i] == 0: | |
| primes.append(i) | |
| j = 2 |