2013-04-01から1ヶ月間の記事一覧

TCHS 10 Online Round 1

medの方がeasyより簡単だと思ったkに近い4の倍数と7の倍数は [k/4]*4 [k/4+1]*4 [k/7]*7 [k/7+1]*7 ([x]はガウスの記号(整数型の割り算)) のうちいずれか #include <cstdio> #include <vector> #include <algorithm> #include <cmath> using namespace std; class TheSequencesLevelOne{ public</cmath></algorithm></vector></cstdio>…

SRM450 div1 easy

ルールを変えたNimでAliceとBobのどちらが必勝かを判定する問題 ルール: 石が1個以上ある山がいくつかある。 プレイヤーは毎回、一つの山から石を1個以上とる。 山は順番に並んでおり、1個以上石が存在する山のうち一番左の山からしか石をとることはできな…

POJ 2378 Tree Cutting

問題 http://poj.org/problem?id=2378 解法 適当な頂点を選んで根にしてDFSして子を数えてやるとできる。 #include <cstdio> #include <algorithm> #include <vector> using namespace std; int N; vector<int> T[10001]; vector<int> ans; int dfs(int p, int q){ int sum = 0; bool f = true; fo</int></int></vector></algorithm></cstdio>…

POJ 2456 Aggressive cows

問題 http://poj.org/problem?id=2456 解法 距離で二分探索。はじめ再帰で書いたが終了条件がよくわからなくてWAになったのでループ回した。 #include <cstdio> #include <algorithm> using namespace std; const int MAX_N = 100000; int N, C; int a[MAX_N]; bool c(int d){ /</algorithm></cstdio>…

POJ 1989 The Cow Lineup

問題 http://poj.org/problem?id=1989 (翻訳)K種類の整数N個からなる整数列が与えられるので、その部分列とならない整数列のうち最短のものの長さを答えろ。 解法 整数列の先頭から、K種類の整数が一通り出るところまで進み、さらにその場所からまたK種類の…