原创 hdu5898 odd-even number 【數位DP】

#include<bits/stdc++.h> using namespace std; typedef long long ll; int num[20]; ll dp[20][20][3]; //dp[i][k] //i:數位

原创 2017年團體程序設計天梯賽-總決賽 L3-1. 二叉搜索樹的結構

注意一下查詢的值不一定都在二叉樹上面 #include<bits/stdc++.h> using namespace std; int n,t,cnt,f[1024],a,b,fa,fb; char s[1024]; map<in

原创 hdu4405 Aeroplane chess【概率DP+期望問題】

#include<bits/stdc++.h> using namespace std; const int N=1e6+5; double dp[N]; int t[N],n,m; int main() { while

原创 hdu5920 Ugly Problem【貪心+高精度減法】

/* *********************************************** Author :Maltub Email :[email protected] Blog

原创 2017年團體程序設計天梯賽-總決賽 L2-2. 重排鏈表

輸入的數據可能不是一張鏈表的,陳越教授風格 #include<bits/stdc++.h> using namespace std; struct node { int add; int d; int ne

原创 數論基礎

0、一些結論 (hdu3501)求1…N中與N互質的數的和:ans=phi(n)*n/2 1、歐幾里德算法 int gcd(int a, int b) { return b == 0 ? a : gcd(b , a%b); }

原创 Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip 【線性DP】

對於每個數字 ai 處理出最左的位置 Lai 和最右的位置 Rai ,然後 dpi 爲前i個數字最大的值,對於每一個 Lai=i 的位置計算出來i到MAX(Rai−Rai) 的異或值,然後更新dp ,最後dpn 爲最後的答案。

原创 Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game【交互題+BFS】

首先要判斷一下LR、DU有沒有交換。一共有三種情況 1. 起點只能向下走 2. 起點只能向右走 3. 起點可以向下或者向右走 之後用bfs找出一條路徑,然後去輸出就可以了。 #include<bits/stdc++.h> usin

原创 實習學習記錄

6月1日 雙向迪傑斯特拉 1. 主要用於解決單個起點和單個終點的問題 2. 分別從起點s 和終點t 開始計算到達其他點的最短路,維護兩個集合S(i) 和 T(i) ,代表s 到i 的最短距離以及t 到i 的最短距離。 3. 每次選

原创 Codeforces Round #444 (Div. 2) C. Solution for Cube【模擬】

學習一波網上簡單的思路,直接判斷旋轉好的情況,一共六種情況。 判最後結果時至少需要四個面。 /* *********************************************** Author :xiang5

原创 vim編譯c++文件設置

爲了從codd::blocks平臺轉移到vim,最近幾天花了好久研究vim,雖然也沒有學會什麼奇技淫巧,但是終於可以編譯c++文件了。 vim和ide比起來,就是秒開,實在受不了vs的龐大,cb的醜陋。 安裝並配置gcc環境 gcc

原创 Codeforces Round #442 (Div. 2) C. Slava and tanks 【找規律】

分成三組 第一組是2 4 6 … 第二組是1 3 5 … 第三組是2 4 6 … #include <stdio.h> #include <string.h> #include <iostream> #include <algor

原创 Codeforces Round #443 (Div. 2) C. Short Program 【模擬】

數字的範圍爲1-1023,所以用二進制表示需要10位。維護一個長度爲10的數組a,分別代表每一位最後的值,取值一共有三種0,1和未知。 對於與操作,a數組對應位置上的數字置爲0。對於或操作,a數組對應位置上的數字置爲1。對於異或操作,如

原创 Codeforces Round #442 (Div. 2) E. Danil and a Part-time Job【線段樹+dfs序】

對原來的圖進行一波dfs,序列化,用線段樹維護。查詢就是線段樹上區間查詢,修改時可以用延遲標記一下。 /* *********************************************** Author :xi

原创 POJ1696 Space Ant 【凸包-ToLeft-Test】

#include<map> #include<set> #include<ctime> #include<cmath> #include<queue> #include<string> #include<vector> #include<