This file contains 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
/* Generate lattice graphs. */ | |
#include "gb_graph.h" | |
#include "gb_basic.h" | |
#include "gb_save.h" | |
int main(int argc, char* argv[]) | |
{ | |
if (argc < 4) { | |
fprintf(stderr, "Usage %s N M outfile\n", argv[0]); |
This file contains 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 <iostream> | |
template<int n, int d = 2, int r = 1, bool is_prime = false> | |
struct Prime { | |
Prime() { Prime<n, (d > 2) ? ((d + 2) % 3 ? d + 2 : d + 4) : d + 1, n % d, (n < d * d)>(); } | |
}; | |
template<int n, int d> | |
struct Prime<n, d, 0, false> {}; |
This file contains 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 python | |
# -*- coding: utf-8 -*- | |
"""世界の標準時間を相互に変換""" | |
import sys, os, datetime | |
TIMEZONE_TABLE = { | |
"NZDT" : ["+13:00", u"ニュージーランド夏時間"], | |
"IDLE": ["+12:00", u"国際日付変更線の東側"], | |
"NZST": ["+12:00", u"ニュージーランド標準時間"], |
This file contains 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
clusters_tbb.cpp | |
// hierarchical clustering using the TBB library | |
// by nox, 2009.07.02 | |
// | |
// Linux - Intel C++ | |
// icpc clusters_tbb.cpp -O3 -ltbb -o clusters_tbb | |
// | |
// Linux - GCC | |
// g++ clusters_tbb.cpp -O3 -ltbb -o clusters_tbb |
This file contains 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 python | |
# -*- coding: utf-8 -*- | |
import sys, os, math, heapq, Image, ImageDraw | |
# Connected Component Labeling - Label Equivalence method | |
class CCL: | |
def __init__(self, imagefile, threshold, area): | |
im = Image.open(imagefile) | |
im = im.convert("RGB") |
This file contains 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
// Solver of Knight's Tour using Warnsdorff's algorithm and Schwenk's theorem | |
#include <iostream> | |
#include <iomanip> | |
#include <vector> | |
#include <algorithm> | |
#include <utility> | |
#include <cmath> | |
#include <cstdlib> |
This file contains 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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <cstdlib> | |
using namespace std; | |
void partitions(int n, int max_n, vector<int>& v, vector<vector<int> >& vv) | |
{ | |
if (n == 0) { |
This file contains 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
// CellularAutomaton.as | |
// by nox, 2010.7.9 | |
// http://handasse.blogspot.com/ | |
/* | |
1-9 : ルール設定 - セルの周りの生存セル数(0-8)に対応 | |
: '.' 死亡, '&' 変化, '+' 誕生, '=' 維持 | |
SPACE : 一時停止 | |
ENTER : リセット | |
V : メッセージ表示/非表示 |
This file contains 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
std::vector<int> primes; | |
for (int i = 3; i < 100; i += 2) primes.push_back(i); | |
auto end = primes.end(); | |
for (auto x = primes.begin(); *x * *x <= *(end-1); ++x) | |
end = std::remove_if(x + 1, end, [&x](int p){ return p % *x == 0; }); | |
primes.erase(end, primes.end()); | |
for (auto p = primes.begin(); p != primes.end(); ++p) std::cout << *p << " "; | |
std::cout << std::endl; |
This file contains 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 cgi,sqlite3,datetime | |
from wsgiref.simple_server import make_server | |
LIMIT=50 # 最大表示記事数. | |
DB_FILE='/sdcard/bbs.sqlite' | |
con=sqlite3.connect(DB_FILE) | |
cur=con.cursor() |