Skip to content

Instantly share code, notes, and snippets.

View making's full-sized avatar

Toshiaki Maki making

View GitHub Profile
@making
making / gist:8777362
Last active August 29, 2015 13:55
aのk乗をmで割った余り = p(a, k, m)
(xy % z) = ((x % z) * (y % z)) % z

k = 2tの場合 a^k = a^t * a^t

p(a, k, m) = (p(a, k/2, m) * p(a, k/2, m)) % m

k = 2t + 1の場合

@making
making / gist:8777551
Created February 3, 2014 01:13
二分探索

vはleft以上、right未満の範囲に存在する

va[left] <= v < va[right]

function contaions(int v, int[] va) {
  if (va.length == 0) {
    return false;
  }
  int left = 0, int right = va.length;
@making
making / Tree.js
Last active August 29, 2015 13:56
javascriptで2分木
// http://jsfiddle.net/L6bfa
var TreeNode = function (value, left, right) {
this.value = value;
this.left = left;
this.right = right;
};
var Tree = function (root) {
this.root = root;
@making
making / tree.go
Created February 5, 2014 05:23
golangで2分木
// http://play.golang.org/p/dB_zEZf_Rz
package main
import "fmt"
type TreeNode struct {
value int
left *TreeNode
right *TreeNode
public interface A {
default int hoge() {
return 100;
}
}
import javax.tools.*;
import javax.tools.JavaCompiler.CompilationTask;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.security.SecureClassLoader;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="com.example.repository.SomeRepository" />
</bean>
<bean class="com.example.service.SomeService"/>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jggug-helloworld</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>jggug-helloworld</name>
<!-- ここから -->
<parent>
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@EnableAutoConfiguration
public class App {
mvn spring-boot:run -Drun.arguments="--server.port=8888"