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 urllib import request | |
from html.parser import HTMLParser | |
import datetime | |
import os.path | |
# urlと保存する場所を指定して画像を一括ダウンロードする | |
class MyHTMLParser(HTMLParser): | |
""" | |
HTMLをparseしてリンクを抜き出す |
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
// | |
// Jacobi.cpp | |
// ヤコビ法(行列の固有値計算) | |
// Created by knuu on 2014/06/23. | |
// | |
// | |
#include <iostream> | |
#include <iomanip> // std::setpricision | |
#include <Eigen/Dense> // 行列計算のライブラリ |
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
// | |
// Power_Method.cpp | |
// Power Iteration | |
// べき乗法 | |
// Created by knuu on 2014/06/23. | |
// | |
// | |
#include <iostream> | |
#include <iomanip> // std::setpricision |
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
class PublicTransit { | |
public: | |
int minimumLongestDistance(int R, int C) { | |
int ret = 200; | |
for (int i = 0; i < R*C; i++) { | |
for (int j = 0; j < R*C; j++) { | |
int dist[110][110]; | |
for (int k = 0; k < R*C; k++) { | |
for (int l = 0; l < R*C; l++) { | |
int i1 = k/C, j1 = k%C, i2 = l/C, j2 = l%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
class LuckyRemainder: | |
def getLuckyRemainder(self, X): | |
N = str(X) | |
D = len(N) | |
pascalTri = [[0]*D for _ in range(D)] | |
for i in range(D): | |
pascalTri[i][0] = 1 | |
pascalTri[i][i] = 1 | |
for j in range(1, i): | |
pascalTri[i][j] = (pascalTri[i-1][j-1] + pascalTri[i-1][j]) % 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
class NumberLabyrinthDiv2: | |
def getMinimumNumberOfMoves(self, board, r1, c1, r2, c2, K): | |
R, C = len(board), len(board[0]) | |
INF = 10**4 | |
dist = [[[INF for _ in range(K+1)] for _ in range(C)] for _ in range(R)] | |
dist[r1][c1][0] = 0 | |
que = Queue.Queue() | |
que.put((r1, c1, 0)) | |
drc = [(-1, 0), (0, 1), (1, 0), (0, -1)] | |
while que.qsize() > 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
import timeit | |
code_list = """ | |
import random | |
l = [random.randint(1, 1000) for _ in range(1000)] | |
que = list() | |
for x in l: que.append(x) | |
for _ in range(1000): que.pop(0) | |
""" | |
code_deque = """ | |
import collections, random |
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 timeit | |
code_heapq = """ | |
import heapq, random | |
l = [random.randint(1, 1000) for _ in range(1000)] | |
pque = [] | |
for x in l: heapq.heappush(pque, x) | |
for _ in range(1000): heapq.heappop(pque) | |
""" | |
code_PriorityQueue = """ | |
import queue, random |
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 check(time): | |
# time以下に箱を取り除けるか | |
box = A[:] | |
now = last | |
for student in range(m): | |
rest = time - now - 1 # 移動時間を引いた、残りの行動可能な時間 | |
if rest <= 0: | |
# 移動できない(もしくは移動しかできない)ときはダメ | |
return False | |
while now >= 0 and rest >= 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
def convert_base(num, base): | |
# numをbase進数に変換 | |
converted = [] | |
while num: | |
num, r = divmod(num, base) | |
converted.append(r) | |
return converted | |
def solve(w, m): | |
m_w = convert_base(m, w) |
OlderNewer