原创 POJ2411-Mondriaan's Dream(輪廓線DP)

題目鏈接 題意 用2*1的骨牌填充滿m*n的矩陣,問有多少種不同的填法。 思路 有、沒有用1、0表示,狀壓DP的思想,但是區別是用的是2*1的骨牌,填一行後可能會有不填的情況,所以輪廓線DP(或插頭DP)就是解決這種每次一行不是整個的問題

原创 POJ2104-K-th Number(靜態主席樹模板 區間第k小)

題目鏈接 You are working for Macrohard company in data structures department. After failing your previous task about key in

原创 P3384 【模板】樹鏈剖分-(樹鏈剖分 模板入門題)

題目鏈接 理解 樹鏈剖分和DFS序很像,都是將樹形轉化爲線形然後用線段樹維護。樹鏈剖分和DFS序的唯一不同就在與走的方向不同:DFS序按照順序走子結點,樹鏈剖分先走重兒子。其他基本一致。 有幾個問題:求一個結點的子樹的所有值。DFS序是連

原创 Exponial (歐拉降冪)

題目鏈接 題意 求這個值 思路 歐拉降冪,剛南京網絡賽補了題,找了一個再練練手.... #include <bits/stdc++.h> using namespace std; typedef long long ll; ll

原创 2019南京網絡賽-B-super_log(歐拉降冪)

題目鏈接 題意 求冪塔函數,b個a mod m . 擴展歐拉定理 歐拉定理概念 代碼參考 理解:這兩種情況必須要分,但是特例很少,所以很多代碼沒有考慮到第二種情況(B>=phi(C))但是仍然可以過,應該是數據水,沒有特例的情況,

原创 HDU6681-Rikka with Cake(轉化爲線段樹模型)

題目鏈接 Problem Description Rikka's birthday is on June 12th. The story of this problem happens on that day. Today is Rikk

原创 2019南京網絡賽B-The beautiful values of the palace(樹狀數組)

題目鏈接 題意 一個螺旋的矩陣,大小爲n*n,n一定爲奇數。有m個位置有值,值就是螺旋矩陣上的值,其他沒有列舉的位置都爲0. 給了x1,y1,x2,y2,求矩形區域(x1,y1)(x2,y2)內所有數的綜合。 思路 求矩形區域,可以轉化爲

原创 POJ2528-Mayor's posters(線段樹+離散化 or 分治+dfs)

題目鏈接 Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign hav

原创 POJ2155-Matrix(二維樹狀數組)

題目鏈接 Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and

原创 HDU4632-Palindrome subsequence(區間DP 迴文子序列)

題目鏈接 Problem Description In mathematics, a subsequence is a sequence that can be derived from another sequence by delet

原创 Codeforces Round #579 div3 E Boxers(思維)

題目鏈接 題意 給一行數有n個,對於每個數可以增大1,也可以減小1,也可以不變,要求修改後必須是正整數,不可爲0。將修改後的數去重,問最多有幾個? #include <bits/stdc++.h> using namespace std

原创 POJ2299-Ultra-QuickSort(樹狀數組 離散化)

題目鏈接 Description In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequenc

原创 HDU2844-Coins(多重揹包 二進制優化 模板)

題目鏈接 Problem Description Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix op

原创 HDU2586-How far away ?(LCA 樹上兩點路徑 tarjan和RMQ做法)

題目鏈接 Problem Description There are n houses in the village and some bidirectional roads connecting them. Every day peol

原创 HDU3506-Monkey Party(區間DP 石子合併 四邊形不等式優化)

題目鏈接 Problem Description Far away from our world, there is a banana forest. And many lovely monkeys live there. One day