ものがどのくらい似ているか=類似度
似ている=相対量
- 他のものがないと判断できない(正例、負例)
# -*- coding: utf-8 -*- | |
# Numericクラスを拡張 | |
class Numeric | |
# 数値の二乗を計算するメソッド | |
# 返り値はfloat | |
def pow | |
self ** 2.0 | |
end | |
end |
# -*- coding: utf-8 -*- | |
# 辺 | |
$edge = [[0,1,2], [0,2,5], [1,2,4], [1,3,6], | |
[1,4,10], [2,3,2], [3,5,1], [4,5,3], | |
[4,6,5], [5,6,9], [1,0,2], [2,0,5], | |
[2,1,4], [3,1,6], [4,1,10], [3,2,2], | |
[5,3,1], [5,4,3], [6,4,5], [6,5,9]] | |
# ダイクストラ法 |
MAX_N = 100 | |
MAX_W = 10000 | |
knap = [ | |
{'weight':2, 'value':3}, | |
{'weight':1, 'value':2}, | |
{'weight':3, 'value':4}, | |
{'weight':2, 'value':2} | |
] |
# -*- coding: utf-8 -*- | |
require 'socket' | |
class Resolver | |
@sock = Socket::new(Socket::AF_INET, Socket::SOCK_STREAM, 0) | |
@fd = @sock.fileno | |
# INETのSTRAMソケットを作成 | |
attr_reader :queue, :results, :dnsserver, :port | |
def initialize |
require 'rubygems' | |
require 'eventmachine' | |
EM.run do | |
resolver = proc do | |
['210.251.121.21', "8.8.8.8"].map do |addr| | |
begin | |
Resolv.getname addr | |
rescue | |
addr |
import std.stdio; | |
/* 要素がすべて無限大である、num_v * num_v の2重配列 */ | |
pure real[][] make_cost(int num_v) | |
{ | |
real[][] cost; | |
cost.length = num_v+1; | |
for(int i;i<=num_v;i++){ | |
cost[i].length = num_v+1; |
import std.stdio; | |
class BinaryIndexedTree { | |
int size; | |
int[] bits; | |
this(int l){ | |
size = l; | |
bits.length = l+1; | |
} |
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require 'socket' | |
class DNSQuery | |
attr_reader :domain_io | |
def initialize data | |
@data = data | |
@domain_io = '' |