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
#coding: Windows-31J | |
# 3行5列のマスを塗っていくパターンは | |
# ある列がそれより左の列の1行目が塗られている場合のみ塗れるので、 | |
# ・1列目だけ塗るパターン | |
# ■ | |
# □ | |
# □ | |
# | |
# ・2列めまで塗るパターン |
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 java.util.ArrayList; | |
import java.util.List; | |
public class Haisen { | |
private static final int ROW = 3; | |
private static final int COL = 5; | |
private static void printAnswer(List<Integer> cols) { | |
for (Integer i : cols) { | |
System.out.print(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
1個塗るパターン------------------------------ | |
1 0 0 0 0 | |
■□□□□ | |
□□□□□ | |
□□□□□ | |
2個塗るパターン------------------------------ | |
1 1 0 0 0 | |
■■□□□ | |
□□□□□ |
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
/** | |
* tmの中で、keyが最初に重複した行数を返す | |
* @param tm | |
* @return | |
*/ | |
private static String checkDuplicate3(TableMessage tm) { | |
//日付をキーに重複した行番号のリストを保持するMap | |
Map<String, List<Integer>> dup = new HashMap<String, List<Integer>>(); | |
//5行分について、同じ日付を持つ行数をまとめる |
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
private static String checkDuplicate2(TableMessage tm) { | |
int NUM = 5; | |
//重複チェックなので、基準値は最後から2番めの要素(NUM-1)までチェック | |
for (int i = 0; i < NUM - 1; i++) { | |
//基準値までの日付はすでにチェック済みなので、基準値の次の要素からチェックする | |
for (int j = i + 1; j < NUM; j++) { | |
if (tm.getRecord(i, "key").equals(tm.getRecord(j, "key"))) { | |
String result = tm.getRecord(i, "num") + ", " + tm.getRecord(j, "num"); | |
//重複が見つかった場合は残りの要素からその日付の行があるか調べる | |
for (int rest = j + 1; rest < NUM; rest++) { |
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
<html> | |
<head> | |
<script> | |
function $id(id) { | |
return document.getElementById(id); | |
} | |
function test(){ | |
alert($id("top_label").style.width); | |
alert($id("left_label").style.height); | |
} |
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
#7を置くパターンを洗い出す | |
#例) | |
#3桁の数字の場合、7が含まれるパターンは | |
#[0, 0, 7] | |
#[0, 7, 0] | |
#[0, 7, 7] | |
#[7, 0, 0] | |
#[7, 0, 7] | |
#[7, 7, 0] | |
#[7, 7, 7] |
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
#引数nのときのオイラー関数の値を返す | |
def phi(n) | |
result = n | |
#まず唯一の偶数の素数2で割れるだけ割る | |
if n % 2 == 0 | |
while n % 2 == 0 | |
n /= 2 #今回は素因数の種類だけが分かればいい(指数は不要なので割るだけ) | |
end | |
#n(1 - 1/p) = n - n/pなので、 result = result - result / 2 => result -= result / 2;と等価になる |
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 class Hikoboshi { | |
/** | |
* 引数nの場合のオイラー関数の値を返す | |
* @param n | |
* @return | |
*/ | |
private static long phi(long n) { | |
long result = n; |
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
class Solver | |
def initialize(first_num) | |
#5~のリストだと考えにくかったため、 | |
#1~のリストに対して、それと5(ここではfirst_numとして変数化)ずれた値を求めるためのオフセット | |
@first_num = first_num | |
end | |
#1から始まる数字の列として考える上で、下記の様に「レンジ」という言葉を定義します | |
#1 2 ... 8 9 10 11 12 13 ... 98 99 100 101 102 ... 998 999 |