0w1

Entries from 2016-02-25 to 1 day

UVA 10382 Watering Grass ( 區間覆蓋問題 )

UVa Online Judge 用畢氏定理把輸入轉換成單純的區間覆蓋問題就可以了。 #include <bits/stdc++.h> using namespace std; const int MAXN = 1e4 + 4; int n; double l, w; double x[MAXN], r[MAXN]; typedef pair<double, double> pdd; pdd p[MAXN]; void solve(){ int m = 0; w /= 2.0; for</double,></bits/stdc++.h>…

UVA 10020 Minimal coverage ( 水題區間覆蓋 )

UVa Online Judge 很單純的區間覆蓋問題。注意覆蓋的是端點而非區間。 #include <bits/stdc++.h> using namespace std; const int MAXLR = 5e4 + 4; const int MAXM = 5000 + 3; const int MAXP = 1e6 + 5; int m; typedef pair<int, int> pii; int n; pii p[MAXP]; void solve(){ sor</int,></bits/stdc++.h>…

UVA 10970 Big Chocolate ( 數學水題 )

UVa Online Judge 給一個 n * m的巧克力,問最少要切幾刀才能全部變成 1 * 1的巧克力,一次只能切在一塊的整數線上。 直覺上把巧克力變成 n條 m個巧克力的條或 m條 n個巧克力的條不會比縱橫亂切差,簡化一下代數又發現這兩種都必須要切 n * m - 1次。。如果…

CF 617E XOR and Favorite Number ( Mo's Algorithm )

Problem - E - Codeforces For a range query [ ql, qr ], we are asked to find the number of distinct pairs that XOR to a given number K. Since it is a range XOR problem, we will consider precomputing prefix XOR pa for the original array a. N…