Skip to content

Instantly share code, notes, and snippets.

@mattsan
mattsan / Permutation.cpp
Created February 22, 2014 12:31
Permutation
#include "Permutation.h"
namespace emattsan
{
unsigned long long factorial(int n)
{
static std::vector<unsigned long long> memo({1});
while(memo.size() <= n)
{
@mattsan
mattsan / file0.cpp
Created April 5, 2014 13:08
第20回オフラインリアルタイムどう書くの問題をC++で解く ref: http://qiita.com/emattsan/items/ee27bbd8965ec73b7add
#include <iostream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <utility>
#include <vector>
#include <bitset>
typedef std::bitset<24 * 60> TimeSlot;
@mattsan
mattsan / file0.cpp
Created April 12, 2014 11:41
第20回オフラインリアルタイムどう書くの問題をC++で解く その2 ref: http://qiita.com/emattsan/items/3913c5124a84abe74ffe
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <map>
inline int toMin(int hm)
{
return (hm / 100) * 60 + (hm % 100);
}
@mattsan
mattsan / file0.cpp
Created April 20, 2014 06:39
第19回オフラインリアルタイムどう書くの参考問題をC++で解く ref: http://qiita.com/emattsan/items/b68e7cd2ad0ada116c4a
#include <iostream>
#include <sstream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <iterator>
class Sanwa
{
public:
static const int UPPER_LIMIT = 120;
@mattsan
mattsan / file0.cpp
Created July 6, 2014 11:03
第23回オフラインリアルタイムどう書く を C++ で解く ref: http://qiita.com/emattsan/items/d51095f9f5285ec84ce1
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
struct Cell
{
int value;
int length;
@mattsan
mattsan / file0.cpp
Created July 8, 2014 13:00
第23回オフラインリアルタイムどう書く を C++のテンプレート で解く ref: http://qiita.com/emattsan/items/cc82b19bf38b3f64f761
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
int get_length(const std::string& values, int pos, int lengths[])
{
if(std::isdigit(values[pos]) && (lengths[pos] == 0))
{
int l[] =
@mattsan
mattsan / das28.rb
Last active August 29, 2015 14:07
DAS28の算出法
def das28_crp(tjc, sjc, crp, pga)
# pga は 0〜100 を期待している
0.56 * Math.sqrt(tjc) + 0.28 * Math.sqrt(sjc) + 0.36 * Math.log(crp * 10 + 1) + 0.014 * pga + 0.96
end
def das28_esr(tjc, sjc, esr, pga)
# pga は 0〜100 を期待している
0.56 * Math.sqrt(tjc) + 0.28 * Math.sqrt(sjc) + 0.70 * Math.log(esr) + 0.014 * pga
end
#include "simple.h"
// {'B' => 456, 'A' => 123}
typedef Environment<NamedNumber<'B', 456>>::Merge<NamedNumber<'A', 123>>::environment environment;
// B => 456
auto b = Variable<'B'>::Evaluate<environment>::value;
// B + A => 579
auto aadd_b_a = Add<Variable<'B'>, Variable<'A'>>::Evaluate<environment>::value;
#!/usr/bin/ruby
# coding: utf-8
require 'date'
begin
raise unless ARGV.size == 3
date_range = ARGV.shift.match(/(\d{1,2}\/\d{1,2})-(\d{1,2}\/\d{1,2})/) { Date.parse($1)..Date.parse($2) }
start_time, end_time = ARGV.shift.match(/(\d{1,2}\:\d{1,2})-(\d{1,2}\:\d{1,2})/) { [DateTime.parse($1), DateTime.parse($2)] }
step = ARGV.shift.to_f
Gem::Specification.new do |spec|
spec.name = "nullpo"
spec.version = "0.0.1"
spec.authors = ["e.mattsan"]
spec.email = ["e.mattsan@gmail.com"]
spec.summary = "null pointer"
spec.files = ["nullpo.rb"]
spec.require_path = "."
end