原创 HDU5492——合肥1009

題目意思是找一條方差最小的路徑 記得以前做過最小方差生成樹,這題要解最小方差路徑也是差不多的。方差與期望相關,而期望和選擇的路徑相關所以沒法直接用期望來求,我用的方法和最小方差生成樹的方法一樣,就是枚舉所有可能的期望值來計算最小

原创 poj1014數據很奇怪DISCUSS更奇怪

寫了一個多小時的DFS感覺對了各種WA,進discuss找數據發現神奇取模方法,不過這個取模方法明顯有問題,再找了別人的DFS秒殺代碼,感覺他們的代碼也明顯有問題,我自己試了好多數據都是對的可是就是WA,還是用DP寫的好,不會WA

原创 Lehmer快速求1e11以內質數個數

#include<cstdio> #include<cmath> using namespace std; #define LL long long const int N = 5e6 + 2; bool np[N]; int p

原创 hdu 5833

#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define maxn 105 #define mod 10000

原创 hdu 5894

#include <bits/stdc++.h> const long long mod=1e9+7; const int N = 1000005 ; long long n , m , k ; long long pw[N

原创 hdu 5976

#include <iostream> #include <cstdio> #include <cmath> #include <string.h> #include <queue> #include <stack> #inclu

原创 hdu 5818

#include <iostream> #include <cstdio> #include <string.h> #include <algorithm> #include <map> #include <queue> #inc

原创 hdu 4393

好久沒寫了 由於不會優先隊列,比較難受 考慮到Fi只有500以內,我一開始感覺是線性規劃。 設Yi=kix+b 取任意兩條直線的交點 x=(b1-b2)/(k1-k2) x的最大值就是499 所以任意兩條直線的交點在500以內,

原创 hdu 4390

題意: Given a number sequence b1,b2…bn. Please count how many number sequences a1,a2,…,ansatisfy the condition thata

原创 Sa求法

#include <iostream> #include <cstdio> #include <math.h> #include <algorithm> #include <string.h> using namespace st

原创 hdu1077模擬

解析幾何,用參數方程解 #include <iostream> #include <math.h> using namespace std; typedef struct P { double x; double

原创 hdu 5877

#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <string> #include <string.h> #inc

原创 hdu 1269 這題有毒

用並查集寫的 題目有毒 n=1,m=0都能輸入,簡直了 #include<stdio.h> #include<string.h> int pre_forward[100010],pre_back[100010]; int n,m

原创 hdu 5971

#include <iostream> #include <cstdio> #include <cmath> #include <string.h> #include <queue> #include <stack> #inclu

原创 hdu1045

水,隨便搜 #include <iostream> #include <string.h> using namespace std; int f[10][10],dp[10][10],n,ans,vis[10][10]; bool