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
modint calc(long long s) { // returns sum(S[0] ... S[pos(s)-1]) | |
modint res; | |
while (n <= s) { | |
res += sum(0, n); | |
s -= n; | |
s *= b; | |
} | |
res += sum(0, s); | |
return res; | |
} |
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
/* エセ Meldable Heap */ | |
/* マージテクを使った簡易的な実装。ただし計算量はlog2つ。 */ | |
// meldable heap (log^2) | |
struct heap { | |
typedef int T; | |
typedef priority_queue<T,vector<T>,greater<T>> TQ; | |
TQ* q; | |
heap():q(new TQ()) {} | |
inline void push(T x) { q->push(x);} |
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
1,6,72,350,1154,3758,14616,56342,206292,709544,2410382, |
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
先手でも後手でもLISを(N+1)/2に出来ることを証明する | |
先手が回ってきたら2を言うと1をパスと同じにできるのでn-=2ができる | |
後手が回ってきて、先手が1ならN、それ以外なら1を言うとn-=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
import twitter # pip install python-twitter | |
from PIL import Image # pip install pillow | |
import datetime, calendar | |
icon_path = 'icon.jpg' | |
save_path = 'tmp.jpg' | |
api = twitter.Api( | |
consumer_key='', | |
consumer_secret='', | |
access_token_key='', |
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 cv2 | |
import numpy as np | |
def fix(name): | |
src = cv2.imread(name) | |
h,w = src.shape[:2] | |
r = min(h,w)/2 - 1 | |
center = np.array([w/2,h/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
import optuna | |
import random | |
n = 5 | |
T = 1000 | |
param_bank = [[1/(n-i) for i in range(n-1)]] | |
def objective(trial): | |
param = [] | |
for i in range(n-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
#include <bits/stdc++.h> | |
#define fi first | |
#define se second | |
#define rep(i,n) for(int i = 0; i < (n); ++i) | |
#define rrep(i,n) for(int i = 1; i <= (n); ++i) | |
#define drep(i,n) for(int i = (n)-1; i >= 0; --i) | |
#define srep(i,s,t) for (int i = s; i < t; ++i) | |
#define rng(a) a.begin(),a.end() | |
#define rrng(a) a.rbegin(),a.rend() | |
#define maxs(x,y) (x = max(x,y)) |
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
#!/usr/bin/env python3 | |
""" | |
辺をランダムに取得し、点数を計算するサンプルプログラムです。 | |
実行には python3 環境が必要です。 | |
TOKEN 変数を書き換えて実行してください。 | |
""" | |
import os | |
import 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
....#...#...#...#...#...#...#...#...#...#...... | |
.##.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.####. | |
..#...#...#...#...#...#...#...#...#...#...#.SS. | |
#BB#########################################SS# | |
PBB..#.....#.....#.....#.....#.....#.....#..... | |
.....#.#......#..#.#......#..#.#......#..#.#... | |
.#...#...........#...........#...........#..... | |
.....#.....#.....#.....#.....#.....#.....#..... | |
##..###..#####..###..#####..###..#####..###..## | |
.....#.....#.....#.....#.....#.....#.....#..... |