Time of Update: 2018-12-05
http://acm.hdu.edu.cn/showproblem.php?pid=1196因為奇數的rightmost位肯定為1,結果也為1;只需處理偶數就ok#include<iostream>#include<vector>#include<map>#include<stack>#include<algorithm>#include<queue>#include<list>#include<set&
Time of Update: 2018-12-05
純數學題,推理如下:已知:1^2+2^2+3^2+……+n^2 =n(n+1)(2n+1)/6 —①那麼1^2+2^2+3^2+……+n^2+……+(2n+1)^2 =(2n+1)(n+1)(4n+3)/3 —②又有2^2+4^2+6^2+……+(2n)^2 =4[1^2+2^2+3^2+……+n^2]=4*①=2n(n+1)(2n+1)/3 —③設所求為S 比較②和③可知 S=②-③=(2n+1)(n+1)(4n+3)/3-2n(n+1)(2n+1)/3=(2n+1)(n+1)(2n+3)/3
Time of Update: 2018-12-05
轉自:http://user.qzone.qq.com/154357274/blog/1287383497計算幾何頭疼的地方一般在於代碼量大和精度問題,代碼量問題只要平時注意積累模板一般就不成問題了。精度問題則不好說,有時候一個精度問題就可能成為一道題的瓶頸,簡直“畫龍點睛”。這些年的題目基本是朝著越來越不卡精度的方向發展了,但是也不乏一些%^&%題#$%$^,另外有些常識不管題目卡不卡,都是應該知道的。今天我就開膛回顧下見過且還有印象的精度問題,由於本人見識和記憶均有限,望各位大神瞄過
Time of Update: 2018-12-05
本題要維護兩個大根堆,用來迴圈維護。。。注意STL heap裡的複雜度#include <vector>#include <list>#include <map>#include <set>#include <queue>#include <string.h>#include <deque>#include <stack>#include <bitset>#include
Time of Update: 2018-12-05
http://www.codeforces.com/contest/79/problem/A很久很久才ac,開始想歪了。。。各種囧啊#include<iostream>using namespace std;#include<string>int n,m;int dfs(int x)//x是標誌,1C贏,2H贏{int a,b;if(n<0 || m<0) return x;if(x==1){a=n;if(a>=2){n-=2;m-=2;}if(a==1
Time of Update: 2018-12-05
http://www.codeforces.com/contest/79/problem/B#include<iostream>using namespace std;__int64 pos[1010];#include<algorithm>int main(){//freopen("a.txt","r",stdin);int n,m,k,t;while(scanf("%d%d%d%d",&n,&m,&k,&t)!=EOF){int
Time of Update: 2018-12-05
貪心http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4351對b從小到大排序就可以了#pragma warning(disable :4786)#include<iostream>using namespace std;#include<algorithm>#include<set>struct node{int a,b;}arm[2510];bool cmp(const node
Time of Update: 2018-12-05
http://acm.hdu.edu.cn/showproblem.php?pid=1698/*修改函數Update():在修改區間的時候,如果正好和區間對應,則改變當前點的value值,如果不對應,則要修改的區間必是當前區間的子區間,再當前區間的兩個子區間修改就行了,關鍵點是:先將當前區間value值賦給它的兩個子區間,同時當前區間的value值要賦零,表示當前區間裡的儲存的值不是同一個值。*/#include<iostream>using namespace
Time of Update: 2018-12-05
貢獻了一次CE!timus竟然不認<string.h>!#include <vector>#include <list>#include <map>#include <set>#include <queue>#include <string>#include <deque>#include <stack>#include <algorithm>#include
Time of Update: 2018-12-05
http://acm.hdu.edu.cn/showproblem.php?pid=2069#include<iostream>using namespace std;int a[5]={1,5,10,25,50},dp[1001][2600];int main(){ //freopen("a.txt","r",stdin); int n; memset(dp,0,sizeof(dp)); dp[0][0]=1; int i,j,
Time of Update: 2018-12-05
zoj的sample是錯的問題是求最小產生樹,還有最長路徑#include <vector>#include <list>#include <map>#include <set>#include <string.h>#include <deque>#include <stack>#include <bitset>#include <algorithm>#include
Time of Update: 2018-12-05
由於2<=n<=10^6,所以一般的求歐拉函數方法用不上,而我們可以根據他的一個性質設a為N的質因數,若(N % a == 0 && (N / a) % a == 0) 則有E(N)=E(N / a) * a;若(N % a == 0 && (N / a) % a != 0) 則有:E(N) = E(N / a) * (a -
Time of Update: 2018-12-05
用二分。。。因為開始時忘記了t=t*sum,調試了很久。。。囧http://acm.hdu.edu.cn/showproblem.php?pid=2035*****************************************************************************************************************************************************************************
Time of Update: 2018-12-05
http://acm.hdu.edu.cn/showproblem.php?pid=1425時間很慢。。。Accepted1425671MS4204K2394
Time of Update: 2018-12-05
最大子矩陣問題:問題描述:(具體見http://acm.pku.edu.cn/JudgeOnline/showproblem?problem_id=1050) 給定一個n*n(0<n<=100)的矩陣,請找到此矩陣的一個子矩陣,並且此子矩陣的各個元素的和最大,輸出這個最大的值。Example: 0 -2 -7 0 9 2 -6 2 -4 1 -4 1 -1 8 0 -2 其中左上方的子矩陣: 9 2 -4 1 -1 8 此子矩陣的值為9+2+(-4)+1+(-1)
Time of Update: 2018-12-05
http://acm.hdu.edu.cn/showproblem.php?pid=1284#include<iostream>//完全背包———0msusing namespace std;#define N 32768__int64 a[3]={1,2,3},dp[N+10];int main(){ //freopen("a.txt","r",stdin); int n; memset(dp,0,sizeof(dp)); dp[0]=1; int i,j,k;
Time of Update: 2018-12-05
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3618很蛋疼,用cin輸入字母竟然TLE!!!#include<iostream>#include<vector>#include<map>#include<stack>#include<algorithm>#include<queue>#include<list>#include<se
Time of Update: 2018-12-05
http://poj.org/problem?id=2828可以從後往前看,那麼pos就變成了前面有幾個空位,線段樹每個區間表示該區間空位有多少。#include <vector>#include <list>#include <map>#include <set>#include <queue>#include <string.h>#include <deque>#include <stack>#
Time of Update: 2018-12-05
很基礎的BFS,不過由於自己太菜鳥,問了青蛙牛才明白**********************************************對於首狀態 1234他的下一個狀態可以是2234 1334 1244 12359234 1134 1224 12332134 1324 1243把這些狀態都放到隊列裡面去,並且把他們的步數記錄為1然後在隊列裡面拉出頭狀態,2234繼續枚舉沒有訪問過的下一個狀態,放到隊列裡面,並且標記他們的步數為2直到找到一個終結的狀態,輸出它的步數。**********
Time of Update: 2018-12-05
http://acm.hdu.edu.cn/showproblem.php?pid=1166***********************************************************本人做的第一道線段樹的題,紀念一下吧***********************************************************/**********************************Accepted 1166 46MS 2476K 1572 B