This file contains hidden or 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
| public int[] getDivision(int[] points) { | |
| int total = 0; | |
| int[] ans = new int[points.length]; | |
| total = arrayTotal(points); | |
| for (int i = 0; i < ans.length; i++) { | |
| ans[i] = (int) Math.floor(((double)points[i]/(double)total) * 100); | |
| } | |
| int otsuri = 100 - arrayTotal(ans); |
This file contains hidden or 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
| public long countRectangles(int width, int height) { | |
| long count = 0; | |
| count = calcCombination(width+1, 2)*calcCombination(height+1, 2); | |
| int short_side = Math.min(width, height); | |
| for (int i = 0; i <= short_side; i++) { | |
| count -=(width - i) * (height - i); | |
| } | |
| return count; | |
| } |
This file contains hidden or 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
| int binarySearch(int[] array, int x){ | |
| int low = 0; | |
| int high = array.length-1; | |
| int mid; | |
| while (low <= high) { | |
| mid = (low + high) / 2; | |
| if(array[mid]< x){ | |
| low = mid + 1; |
This file contains hidden or 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
| int binarySearchRecursive(int[] array, int x, int low, int high){ | |
| if(low > high) return -1; | |
| int mid = (low + high) / 2; | |
| if (array[mid] < x) { | |
| return binarySearchRecursive(array, x, mid + 1, high); | |
| }else if(array[mid] > x){ | |
| return binarySearchRecursive(array, x, low, mid - 1); | |
| }else{ | |
| return mid; | |
| } |
This file contains hidden or 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
| void mergeSort(int[] array, int low, int high){ | |
| if(low < high){ | |
| int middle = (low + high) / 2; | |
| mergeSort(array, low, middle); | |
| mergeSort(array, middle+1, high); | |
| merge(array, low, middle, high); | |
| } | |
| } | |
| void merge(int[] array, int low, int middle, int high){ |
This file contains hidden or 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
| void quickSort(int[] array, int left, int right){ | |
| int index = partition(array, left, right); | |
| if(left < index - 1){ | |
| quickSort(array, left, index - 1); | |
| } | |
| if(index < right){ | |
| quickSort(array, index, right); | |
| } | |
| } |
This file contains hidden or 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
| ArrayList<ArrayList<Integer>> getSubsets(ArrayList<Integer> set, int index){ | |
| ArrayList<ArrayList<Integer>> allSubsets; | |
| if(set.size() == index){ | |
| allSubsets = new ArrayList<ArrayList<Integer>>(); | |
| allSubsets.add(new ArrayList<Integer>()); //空集合追加 | |
| }else{ | |
| allSubsets = getSubsets(set, index+1); | |
| int item = set.get(index); | |
| ArrayList<ArrayList<Integer>> moreSubset = new ArrayList<ArrayList<Integer>>(); |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| use utf8; | |
| use Text::MeCab; | |
| use Text::TermExtract; | |
| use TermExtract::MeCab; | |
| use Data::Dumper; | |
| _extract_keyword(); |
This file contains hidden or 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
| import random | |
| import sys | |
| argvs = sys.argv | |
| members = argvs[1:] | |
| random.shuffle(members) | |
| for i in xrange(0,len(members)): | |
| if(i%2 == 1): | |
| print members[i] |
This file contains hidden or 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
| import random | |
| import sys | |
| argvs = sys.argv | |
| members = argvs[1:] | |
| random.shuffle(members) | |
| members.append("teacher") | |
| for i in xrange(len(members)/2): | |
| print str(members[2*i]) + ":" + str(members[2*i+1]) |