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 math | |
| import collections | |
| class GeometricProgressions: | |
| def count(self, b1, q1, n1, b2, q2, n2): | |
| s = set() | |
| self.primes = self._primetable(int(math.ceil(math.sqrt(max(b1, q1, b2, q2))))) | |
| self._check01(b1, q1, n1, s) | |
| self._check01(b2, q2, n2, s) | |
| return len(s) |
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 collections | |
| class GeometricProgressions: | |
| def count(self, b1, q1, n1, b2, q2, n2): | |
| s = set() | |
| self._add_set(b1, q1, n1, s) | |
| self._add_set(b2, q2, n2, s) | |
| return len(s) | |
| def _add_set(self, b, q, n, s): |
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
| # -*- coding: utf-8 -*- | |
| import tweepy | |
| class Tw: | |
| def __init__(self): | |
| consumer_key = '' | |
| consumer_secret = '' | |
| oauth_token_secret = '' | |
| oauth_token = '' |
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 itertools | |
| class ConvertibleStrings: | |
| def leastRemovals(self, A, B): | |
| candi = list(set(A + B)) | |
| perms = itertools.permutations(candi) | |
| mini = 55 | |
| for perm in perms: |
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 <vector> | |
| #include <list> | |
| #include <map> | |
| #include <set> | |
| #include <queue> | |
| #include <deque> | |
| #include <stack> | |
| #include <bitset> | |
| #include <algorithm> | |
| #include <functional> |
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 itertools | |
| import bisect | |
| def solve(items, camps): | |
| combi = itertools.combinations(items, 2) | |
| sums = [a+b for a, b in combi] | |
| sums.sort() | |
| for camp in camps: | |
| i = bisect.bisect_right(sums, camp) |
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 Queue | |
| def solve(k, strs): | |
| strsX = [] | |
| for str in strs: | |
| strsX.append(list(str.replace('.', 'X'))) | |
| num_X = countX(strsX) | |
| strsX = replaceX(strsX, num_X - 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
| def combination(n, m): | |
| a, b = 1, 1 | |
| if m > n / 2: | |
| m = n - m | |
| for i in xrange(m): | |
| a *= n - i | |
| b *= i + 1 | |
| return 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
| import math | |
| import string | |
| class FoxAndWord: | |
| def howManyPairs(self, words): | |
| cnt = 0 | |
| for i, word in enumerate(words): | |
| for j in xrange(i + 1, len(words)): | |
| if len(words[j]) != len(words[i]): #Contest中書き忘れたとこ。 |
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
| #これでほかのページからhoge = new Hoge() | |
| #hoge.a()ってやると、bがありませんって言われるのなんでーーー。 | |
| #hoge.b(date)は呼べるよー( ・ั﹏・ั) | |
| class @Hoge | |
| a: ()=> | |
| now = new Date() | |
| b(now) | |
| b: (date)=> |