Skip to content

Instantly share code, notes, and snippets.

View tomoki's full-sized avatar

Tomoki Imai tomoki

View GitHub Profile
@tomoki
tomoki / prime.cpp
Last active December 10, 2015 23:19
エラトステネスの古い(ver.2)
#include <iostream>
#include <cmath>
using namespace std;
const int M = 1e7+10;
bool isPrime[M];
void sieve(){
for(int i=2;i<M;i++) isPrime[i] = true;
@tomoki
tomoki / prime.cpp
Created November 29, 2012 10:01
エラトステネスの篩
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const int MAX = 1000000;
vector<int> Primes;
void sieve(){
@tomoki
tomoki / .vimrc
Created October 23, 2012 18:27
hankaku.
function! HankakuSpace()
highlight HankakuSpace cterm=underline ctermfg=darkgrey gui=underline guifg=darkgrey
endfunction
if has('syntax')
augroup HankakuSpace
autocmd!
"ZenkakuSpaceをカラーファイルで設定するなら次の行は削除
autocmd ColorScheme * call HankakuSpace()
@tomoki
tomoki / template.tex
Created October 16, 2012 14:33
Template.tex
\documentclass{article}
\usepackage[a4paper,margin=3cm]{geometry}
\usepackage{euler}
\usepackage[no-math]{fontspec}
\usepackage{xltxtra}
\usepackage{listings}
\usepackage{graphicx}
@tomoki
tomoki / nf.ml
Created August 15, 2012 07:35
num_of_float
open Num
let num_of_float f =
let is_float_integer fl =
float_of_int((int_of_float fl)) = fl
in
let rec sub_num_of_float fl beg =
if is_float_integer fl then
num_of_int (int_of_float fl) // num_of_int beg
else
@tomoki
tomoki / fizzbuzz.ml
Created August 7, 2012 14:39
fizzbuzz
let fizzbuzz n =
let rec sub_fizzbuzz x lis =
if x <= 0 then
lis
else
if x mod 15 = 0 then
sub_fizzbuzz (x-1) ("fizzbuzz"::lis)
else if x mod 3 = 0 then
sub_fizzbuzz (x-1) ("fizz"::lis)
else if x mod 5 = 0 then
@tomoki
tomoki / main.c
Created June 16, 2012 13:44
List test
#include <stdio.h>
#include <stdlib.h>
typedef struct list_node {
int value;
struct list_node *next;
} *node;
typedef struct list_struct{
node head;
@tomoki
tomoki / hash.c
Created May 16, 2012 00:58
Hash structure
#include "hash.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
int hash_func(Hash hash,int key1,int key2);
int rehash_func(Hash hash,int gened_key);
void expand(Hash hash,size_t new_size);
@tomoki
tomoki / fib2.c
Created May 11, 2012 08:26
Fibonacci
#include <stdio.h>
long long fibiter(long long a,long long b,long long p,long long q,long long count){
if(count == 0){
return b;
}
if(count % 2 == 0){
return fibiter(a,b,(p*p+q*q),(2*p*q+q*q),(count/2));
}else{
return fibiter((b*q+a*q+a*p),(b*p+a*q),p,q,(count-1));
@tomoki
tomoki / sinri.tex
Created March 10, 2012 10:00
titech 心理学レポート
\documentclass{article}
\title{人間の記憶のメモリモデル}
\usepackage{xltxtra}
\setmainfont{VL Gothic}
\XeTeXlinebreaklocale "ja"
\author{*******TomokiImai}