Time of Update: 2018-12-05
首先簡述下在myeclipse 下建立 監聽程式的小過程在 src 下建立個listener 檔案夾,然後在此檔案夾下 new -> class 然後在點 add 輸入 servletContextlistener 確定就OK 了最後 修改 web.xml 就完成 了 jsp 頁面內容<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
Time of Update: 2018-12-05
題意:兩個罐子倒水題解:#include<cstdio>#include<algorithm>#include<cstring>using namespace std;int a, b, n;bool vis[1010][1010], flag;int res[10100], step;void print(){ for(int i = 0; i < step; i++) { switch(res[i]) {
Time of Update: 2018-12-05
題意:加密、解密題解:#include<cstdio>#include<algorithm>#include<cstring>using namespace std;int key;int c2i[1000];char i2c[1000];void init(){ for(int i = 'a'; i <= 'z'; i++) c2i[i] = i - 'a' + 1; c2i['_'] = 0; c2i['.'] = 2
Time of Update: 2018-12-05
#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;#define MAXN 100001#define L(u) (u<<1)#define R(u) (u<<1|1)#define MID(l, r) ((l+r)>>1)struct SegTree{ int l, r;}
Time of Update: 2018-12-05
題意....題解:#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;#define MAXN 100001#define L(u) (u<<1)#define R(u) (u<<1|1)struct A_NODE{ A_NODE *sun, *bro; int num;}
Time of Update: 2018-12-05
登入介面login_form.jsp<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><
Time of Update: 2018-12-05
題意:下標模5等於3的數的和。題解:可以這樣,線段樹的每個節點存一個數組 sum[5],表示當前節點覆蓋的區間中,從左到有編號,模 5 為 0,1,2,3,4的所有數的和每個節點再儲存一個當前節點所包含的區間中有多少個數的資訊:cnt。那麼: 添加的時候就是在相應的位置把整數加進去,並把 cnt+1 刪除的時候就是在相應的位置賦值為 0,並把 cnt-1關於 pushUp 的問題,我們可以這樣考慮: 父親的 cnt 肯定是兩個兒子的 cnt 的和
Time of Update: 2018-12-05
題意: According to a research, VIM users tend to have shorter fingers, compared with Emacs users. Hence they prefer problems short, too. Here is a short one: Given n (1 <= n <= 1018), You should solve for g(g(g(n))) mod 109 + 7 whereg(n) = 3g(
Time of Update: 2018-12-05
題意:。。。題解:將所有的數從小到大排序。證明一個性質:若一個數num[i]被選中,那麼一定要選num[i-1]或者num[i+1]來與它配對,這樣才能使差方最小。例如有下面四個數,他們從小到大到分別為x, x+a, x+a+b, x+a+b+c選擇(x,x+a),(x+a+b,x+a+b+c) ,差方=a^2+c^2選擇 (x,x+a+b),
Time of Update: 2018-12-05
這題也是很明顯的差分約束,找負環 對於條件a,b,c,a-b=c轉化成a-b>=c&&a-b<=c,條件a,b,約束為a-b>=1 添加超級源點V0,到所有點的權值為0,如果發現負環,則情報不可信 用Bellman-Ford,加不加最佳化差距很明顯,不加最佳化就TLE,加了後只要600MS左右 代碼:#include<iostream>using namespace std;const int MAX=1005;const int inf=1<
Time of Update: 2018-12-05
不錯的題目,看了別人的解體報告才會,膜拜大牛!http://hi.baidu.com/saintlleo/blog/item/ab5e6b1b65f538c5a7866906.html 把男女分為左右兩個集合,如果男a喜歡女b,a向b連一條邊,對於題目給的完美匹配,女b向男a連一條邊 然後求強連通分量,如果一個男的和某些女的在一個強連通分量中,他們可以結婚,注意,女的要在男人喜歡的名單中找,可能有一些男女在同一個連通分量中,但是男的不喜歡女的 如果某些男女在一個強連通分量中
Time of Update: 2018-12-05
要求n^n的最右邊一位,由觀察可知,這一位的結果只與n的個位上的數字有關結果為((n%10)^n)%10,線性暴力求解逾時了,用二進位加速 代碼:#include<iostream>#include<cstdio>using namespace std;int pow(int p,int n){int a=p,ret=1;while(n){if(n&1)ret=ret*a%10;a=a*a%10;n>>=1;}return ret;}int main(
Time of Update: 2018-12-05
對於別人來說很水的題,對我來說很難。。。唉 首先,這道題抽象成一張有向圖,由於magic power的存在,使得這張圖中存在環,於是想到用強連通分量縮點的方法,把這張圖變成DAG圖(有向非循環圖),把每個分量中各個點的權值累加(注意可能為0) 然後從左上方的點所在的分量開始,求一條最長的一條帶權路徑,有很多方法,網上說的有拓撲排序,Bellman-Ford(運用記憶化搜尋),DFS等等,由於資料量小,我就用了拍起來比較簡單的DFS 這道題又被讀題給害了, in the order from
Time of Update: 2018-12-05
求1~n中每個數與n的最大公約數的和我的方法,先因式分解n,然後dfs求出n的所有約數,與n的最大公約數一定是n的某個因數,我們只要知道對每個d|n,gcd(i,n)=d,1<=i<=n,有幾個i滿足,即1~n中與n的最大公約數為d的數位個數就好了,而這個個數正好是PHI(n/d),PHI為歐拉函數 網上看到別人一個利用積性函數解決的http://scturtle.is-programmer.com/posts/19388.html在數論中的積性函數:對於正整數n的一個函數 f(n)
Time of Update: 2018-12-05
題意:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4970題解:#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define MOD 55566677#define lint long long#define MAXN 52int fa[MAXN];int n, m;int a[MAXN][
Time of Update: 2018-12-05
題意:求樹上兩個節點的最近公用祖先演算法一:tarjanLCA(u) { Make-Set(u) ancestor[Find-Set(u)]=u //設定u所在集合的祖先 對於u的每一個孩子v { LCA(v) Union(v,u) //把v產生的子集併入u中 ancestor[Find-Set(u)]=u //防止採用樹形啟發學習法合并使u的集合根(代表)變化 } checked[u]=true 對於每個(u,v)屬於P { if
Time of Update: 2018-12-05
題目:http://acm.hdu.edu.cn/showproblem.php?pid=3966題解:#include<cstring>#include<cstdio>#include<algorithm>#include<vector>using namespace std;#define MAXN 50010#define L(u) (u<<1)#define R(u) (u<<1|1)//寫在類裡面爆棧int n,
Time of Update: 2018-12-05
這次的輸入輸出居然要用IO流,搞得我一開始提交了幾次不成功,出錯問題也看不懂。。。看了首頁的comment才發現問題 A 水題,每次交換兩個位置的值(1表示有球,0表示沒球),最後輸出值為1的位置 代碼:#include<iostream>#include<algorithm>using namespace std;int a[4];int main(){int i,j,k,ball,count;freopen("input.txt", "rt", stdin);
Time of Update: 2018-12-05
與POJ 3216類似,不過這道題兩站之間的距離是曼哈頓距離,不要Floyd求最短距離 代碼:#include<iostream>using namespace std;struct node{int start;int end;int a,b,c,d;}ride[500];int m,g[505][505];int link[505],u[505];int dfs(int t){for(int i=1;i<=m;i++){if(g[t][i]&&!u[i])
Time of Update: 2018-12-05
兩個題一樣的意思,而且3177的資料很少,拿3522的去交,不用改大小都過了。。。 題目意思是要讓無向圖任意兩點間至少有兩條路徑可達,先求出邊雙連通分量,求橋,把橋刪除後縮點求度,度為1的點(葉子)個數為x,x!=1(一個雙連通分量),答案為0,否則答案為(x+1)/2 代碼:#include<iostream>using namespace std;const int MAX=5001;struct node{int v,op,next,vis;}g[MAX*6];int dfn[