Skip to content

Instantly share code, notes, and snippets.

View stmtk1's full-sized avatar

Motoki saito stmtk1

View GitHub Profile
import Control.Monad.State.Strict
import System.Random
main = do
print "hello world"
print $ evalState (genPrimes 100) [2]
isPrime :: Int -> [Int] -> Bool
isPrime n primes = all (\p -> mod n p /= 0) primes
template<typename T>
std::vector<T> thread_map(int thread_num, std::vector<T> origin_arg, std::function<T(T)> func) {
std::vector<std::thread> threads_;
std::vector<T> output_(origin_arg.size());
for(int i = 0; i < thread_num; ++i){
auto runner = [i, func, origin_arg, thread_num, &output_]() {
int array_size = origin_arg.size();
int start = (array_size + thread_num - 1) / thread_num * i;
int end = std::min((array_size + thread_num - 1) / thread_num * (i + 1), array_size);
for(int j = start; j < end; ++j) {
use regex::Regex;
use std::cell::RefCell;
use std::rc::Rc;
fn main() {
println!("{:?}", Parser::new("(+ 1234 1)").token_tree);
}
#[derive(Clone, Debug)]
enum Token {
use std::io::{self, Read};
use std::rc::Rc;
use std::cell::RefCell;
fn main() -> io::Result<()>{
let mut buffer = String::new();
let stdin = io::stdin();
let mut handle = stdin.lock();
handle.read_to_string(&mut buffer)?;
let tokens = str2token(buffer);
pub const TEST: u64 = 100;
use std::rc::Rc;
use std::cell::RefCell;
struct BinTree {
value: u64,
left: Option<Rc<RefCell<BinTree>>>,
right: Option<Rc<RefCell<BinTree>>>,
}
impl BinTree {
use std::rc::Rc;
use std::cell::RefCell;
use std::fmt::{ self, Display };
enum MyNumber {
One(Rc<RefCell<MyNumber>>),
Zero,
}
impl MyNumber {
use std::sync::{ Arc, Mutex };
#[derive(Debug)]
struct BinTree {
left: Option<Arc<Mutex<BinTree>>>,
right: Option<Arc<Mutex<BinTree>>>,
value: u64,
}
impl BinTree {
use std::cell::RefCell;
use std::rc::Rc;
use std::collections::LinkedList;
#[derive(Debug, Clone)]
struct VueGraph {
parent: Vec<Rc<RefCell<VueGraph>>>,
name: String,
children: Vec<Rc<RefCell<VueGraph>>>,
}
import java.io.*;
import java.util.Random;
import java.util.Date;
import java.util.StringTokenizer;
class Species {
protected double max; // 最大適応度
protected double mean; // 平均適応度
protected double [] pi; // 適応度