原创 143 - ZOJ Monthly, October 2015

【A Ant】 比賽的時候公式推出來了,可是取模那一塊弄錯了,一直wa 假設另外兩條邊是x,y 那麼最短的路線就是len = x^2 + y^2 + n^2 + 2*x*y 這個公式分成三個部分求 s1 = sum(x^2 + y^2)

原创 Codeforces Round #323

div. 2 【A. Asphalting Roads】 #include <cstdio> #include <cstring> int h[100],v[100]; int k[3000]; int main() { int n;

原创 Codeforces Round #327

div. 2 【A. Wizards' Duel】 #include <bits/stdc++.h> using namespace std; int main() { int l,p,q; scanf("%d%d%d",&l, &

原创 Codeforces Round #328 (Div. 2)

【A. PawnChess】 白棋跟黑棋只能往上或往下走,如果有阻礙就無法通過 w到第一行的最小距離是s1 b到最後一行的距離是s2 s1 <= s2,那就是輸出A 否則輸出B <span style="font-size:14px;"

原创 樹形dp題集之樹的直徑

前言: 所謂的樹的直徑就是樹上兩點之間的最大距離 求樹的直徑有三種方法,三種方法詳解 【codeforces 592D】 這一題寫過博客的點擊打開鏈接 <span style="font-size:14px;"><span style

原创 hash

【UVA 10125】Sumsets 在一串大小爲s的數列中,是否存在a + b + c = d, 如果存在,輸出最大的d,否則輸出no solution 這題的數據很水,直接暴力也是能過的 #include <bits/stdc++.h

原创 codeforces 381E Sereja and Brackets(線段樹)

題目鏈接:【E. Sereja and Brackets】    線段樹 輸入一串括號串,m次詢問,每次輸出區間[l,r]之間配對的括號最多是多少 配對的括號是‘()’,除此之外全不是配對的 a[i]表示到i爲止一共有多少括號對 b[i]

原创 中途相遇法

【FZU  2178】禮物分配(經典題) <span style="font-size:14px;"><span style="font-size:14px;">#include <iostream> #include <algorit

原创 Educational Codeforces Round 1

【A. Tricky Sum】 先預處理2的i次方,用p[ ]記錄,p[ 0 ] = 1, p[ 1 ] = 2, p[ 2 ] = 4…… sum(n) = (1+n)*n / 2 - 2*p[ 0 ] - 2*p[ 1 ] - ……

原创 Codeforces Round #325

div. 2 【A. Alena's Schedule】 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <s

原创 Codeforces Round #262

div. 2 【A. Vasya and Socks】 #include <bits/stdc++.h> using namespace std; int main() { int n,m; scanf("%d%d", &n, &m

原创 Codeforces Round #326

div. 2 【A. Duff and Meat】 #include <iostream> #include <cstdio> int a[100005],p[100005]; int main() { int n,minv=10000

原创 Codeforces Round #322 (Div. 2)

【A. Vasya the Hipster】 #include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <

原创 樹形dp之刪邊

【Codeforces Round #263 (Div. 2) D. Appleman and Tree】 一棵由n個點組成的樹,標號爲0~n-1 輸入n-1個數字pi,表示pi與i+1相連 輸入n個數xi,xi=0表示這個節點是白色,x

原创 codeforces 589C Polycarp's Masterpiece(分治 折半搜索)

【2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)】 給你一個字符串s, n次