原创 求逆序對個數(樹狀數組)
#include<iostream> #include<algorithm> #define ll long long using namespace std; const int maxn=100010; struct node{
原创 [UVA10003] 切木棍(dp)
**樣例: 100 3 25 50 75 10 4 4 5 7 8 0 ** #include<iostream> using namespace std; const int maxn=1010; int f[maxn]
原创 【luogu3853】路標設置(二分,模擬)
題目大意 把公路上相鄰路標的最大距離定義爲該公路的“空曠指數”,給出個路標距起點的距離,求最小“空曠指數”值 簡單二分+模擬即可 #include<iostream> using namespace std; const int max
原创 線段樹模板
334的蠢碼 廢話不說,貼碼 #include<iostream> using namespace std; long long sum[500100*4+1]; void pushup(int rt){ sum[rt]=s
原创 包含第k元素LIS(dp)
輸入樣例 8 6 65 158 170 299 300 155 207 389 輸出樣例 4 #include<iostream> using namespace std; const int maxn=1010; i
原创 [UVA1626]Brackets sequence(dp)
樣例: 1 ([(] #include<iostream> #include<cstring> #include<algorithm> using namespace std; const int INF=1<<30; const in
原创 繪製二叉樹
# 1、小寫字母“o”表示結點,對於一個父親結點,分別用“/”、“\”連接左、右子樹。 2、定義[i,j]爲位於第i行,第j列的某個字符。若[i,j]爲“/”,那麼[i-1,j+1]與[i+1,j-1]只可能是“o”或者“/”。若
原创 【luogu2759】奇怪的函數(二分,數論)
一個換底公式解決的事 https://www.luogu.org/problemnew/show/P2759 題摘使得 x^x 達到或超過 n 位數字的最小正整數 x 是多少? 求x^x次方的位數,可用x*
原创 點的最短路徑
FLOYD for (int k=1;k<=n;k++) for (int i=1;i<=n;i++) for (int j=1;j<=n;j++)
原创 樹狀數組模板
模板廢話 #include<iostream> #define ll long long using namespace std; const int maxn=500010; int n,m; int bit[maxn]; void
原创 [luogu3397]地毯(二維線段樹組)
在n*n的格子上有m個地毯。 給出這些地毯的信息,問每個點被多少個地毯覆蓋。 輸入樣例#1: 5 3 2 2 3 3 3 3 5 5 1 2 1 4 輸出樣例#1: 0 1 1 1 0 0 1 1 0 0 0 1 2 1
原创 [codevs1213]解的個數(數論,擴歐)
已知整數x,y滿足如下面的條件: ax+by+c = 0 p<=x<=q r<=y<=s 求滿足這些條件的x,y的個數。 #include<iostream> #define ll long long using namespace st
原创 [luogu1429]平面最接近點對(二分)
給定平面上n個點,找出其中的一對點的距離,使得在這n個點的所有點對中,該距離爲所有點對中最小的 #include <iostream> #include <algorithm> #include <cmath> #include <cst
原创 [luogu1004]方格取數(dp,亞瑟)
某人從圖中的左上角的A出發,可以向下行走,也可以向右行走,直到達右下角的B點。在走過的路上,他可以取走方格中的數(取走後的方格中將變爲數字0)。 此人從A點到B點共走了兩次,試找出兩條這樣的路徑,使得取得的數字和爲最大。 INPUT
原创 樹狀數組(區間更新區間查詢)
#include<iostream> #define ll long long using namespace std; const int maxn=200010; int n,q,data; long long bit0[maxn