Skip to content

Instantly share code, notes, and snippets.

// oriに長さ50のスコアがいい文字列を渡す
// lower_score以下の部分文字列はその文字列は枝返り、ok_scoreが見つかったら他の部分文字列は枝返り
void get_substr(const string& ori, int lower_score, int ok_score, int len = 8)
{
bool ignore[55][55];
clr(ignore, 0);
set<string> visit;
queue<string> q;
q.push(ori);
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
@takapt
takapt / kyoprotest.py
Last active August 29, 2015 14:06
競プロテスター
#!/usr/bin/env python3
import re
import html
from bs4 import BeautifulSoup
import requests
class TestCase:
@takapt
takapt / gist:7acaa25174032eef7833
Created September 21, 2014 20:00
prime factor
class PrimeFactor
{
public:
int n;
vector<int> factor;
PrimeFactor(int n)
: n(n), factor(n + 1, -1)
{
for (int i = 2; i <= n; ++i)
{
@takapt
takapt / gist:08372f1bacd9811190c7
Created September 20, 2014 18:15
leep year!!
//// Date
// __days[month - 1]
static const int __days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
// __sum_days[month] -> sum_days(1, 2, .., month - 1)
static const int __sum_days[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
const int days_of_year = 365;
class Date
@takapt
takapt / gist:0487ad4cb2442334bb70
Last active August 29, 2015 14:06
min cost partition
template <typename T>
class Dinic
{
struct DinicEdge
{
int to;
T cap;
int rev;
DinicEdge(int to, T cap, int rev)
: to(to), cap(cap), rev(rev) {}
@takapt
takapt / cf.rb
Created April 24, 2014 05:09
codeforcesのsample自動テスト
#!/usr/bin/env ruby
require 'fileutils'
require 'open-uri'
require 'nokogiri'
require 'open3'
class Test
attr_accessor :number, :input, :output
@takapt
takapt / sosu.rb
Created February 1, 2013 06:01
適当に拾ってきたやつ
class Integer
def prime?
n = self.abs()
return true if n == 2
return false if n == 1 || n & 1 == 0
d = n-1
d >>= 1 while d & 1 == 0
10000.times do # 20 は上の説明の k に相当
a = rand(n-2) + 1
t = d
1.upto(0.0/0){|n| puts n or break if (1..6).map{|i| (n * i).to_s.split(//).sort}.uniq.length == 1}