Time of Update: 2018-12-04
不想做過多的理論說明,舉個例子吧。有個鞋廠,生產耐克,李寧的鞋子,用代碼實現,怎麼做呢?Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 package org.gunct.pattern; 2 3 public class ShoesFactory { 4 5 public void getNikeShoes() 6
Time of Update: 2018-12-04
由於web天生並發性,導致我們的一般java工具類會在這樣的環境下出現問題。其實問題的根源就是我們的工具類不是安全執行緒的。有一個產生md5的工具類:public class MD5 { private static long[] state = new long[4]; private static long[] count = new long[2]; private static byte[] buffer = new byte[64]; private
Time of Update: 2018-12-04
最近的項目中遇到一個根據一個表的ID來將表A的部分列資料添加到表B中.考慮使用遊標對於效能的影響,且表A的主鍵是自增的數值型,所以採用擷取最大值與最小值的方法來添加資料.方法如下:declare @maxID bigintdeclare @minID bigint--設定初始值set @maxID = 0set @minID = 0--計算最大值與最小值select @minID=MIN([ID]) FROM Table_A WHERE 條件select @maxID=Max([ID])
Time of Update: 2018-12-04
工作三年了,各個方面都表現不錯,但是職位上一直沒有什麼變化。眼看跟公司的合約到期了,公司為了留住人才,提拔我作了部門經理,呵呵,真是很高興。
Time of Update: 2018-12-04
文章目錄 代碼1,這個有點長,但是很好理解代碼2:難理解一點 上一篇一道題目用到了篩選素數,不過是那個只需要求3400以內的,比較少,無所謂,關鍵是如果要求1000000以內的,再直接求就不行了,太慢了。下面給出兩個自己用的模版,並解釋解釋,為何這樣能夠很快計算出素數。代碼1,這個有點長,但是很好理解#include <stdlib.h>#include <stdio.h>#include <string.h&
Time of Update: 2018-12-04
dfs個人第一題,費盡千辛萬苦,終於AC,一AC解萬愁。果然自己親自敲代碼的過程學到不少。必作一總結。 先附代碼,修改比較多,so,比較醜。 #include<stdio.h>#include<string.h>int pan[30][30];int fa[1000][2];int count;char
Time of Update: 2018-12-04
int ans[200];int fa[200];int n;void toposort(){ int cnt=0; memset(in,0,sizeof(in)); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { if(adj[i][j]==1) in[j]++; } for(int i=1;i<=n;i++)
Time of Update: 2018-12-04
#include <iostream>#include <cstring>#include<cmath>#include<algorithm>#include<vector>const double N=-1e-10;using namespace std;int bz[1005];struct point{double x,y;};vector<point> a[100005];int xj(point x1,point
Time of Update: 2018-12-04
二維數組,高精度加法,兩個大數比較大小……二維數組,高精度加法,兩個大數比較大小……#include<iostream>#include<string.h>using namespace std;char a[600][150]={"0","1","2"};void add(char s1[],char s2[],char a[])//大數加法{ int i,j,k,sum=0;
Time of Update: 2018-12-04
//方法1:#include <iostream>#include <cstdio>#include <map>#include <string>#include <cstring>#include <algorithm>using namespace std;struct compute{int zl,jg,pz;}d[1005];int init[1005],n,w,Count;map<string,int>
Time of Update: 2018-12-04
#include <iostream>#include<cstdio> using namespace std;struct DNA{int a,c,g,t;}d[1005];int main(int argc, char *argv[]){int t,n,m,i,j,ans,max;char s[1005];cin>>t;while(t--){ scanf("%d%d",&n,&m); for(i=0;i<m;i++)d[i].a=
Time of Update: 2018-12-04
此題運用快速冪和組合公式對於選人的方案可以是:∑C(n,k)C(k,1) 其中k從1到n 所有組合數相加。對於C的公式有:C(n,k)C(k,r)=C(n,r)C(n-r,k-r)(k>=r)化簡後 C(n,1)C(n-1,k-1)其中C(n,1)是常數n提出來,那麼裡面就是∑C(n-1,k-1)其中k從1 到n 那麼這個就是組合公式的全集 也就是2^(n-1)所以此題答案就是n*(2^(n-1)) 但是n打到10^9 所以需要用到快速冪。#include
Time of Update: 2018-12-04
#include <iostream>using namespace std;char map[15][15];int n;char min_A(int i,int j){char a='A';int flag=1;while(flag){ flag=0;if(i>0&&map[i-1][j]==a) {flag=1;a++;}if(i+1<n&&map[i+1][j]==a)
Time of Update: 2018-12-04
題意:輸入一個進位b,在輸入兩個基於b進位的大整數 x,y ,求x%y的b進位結果。http://162.105.81.212/JudgeOnline/problem?id=2305函數:String st = Integer.toString(num, base); // 把num當做10進位的數轉成base進位的st(base <= 35).int num = Integer.parseInt(st, base); //
Time of Update: 2018-12-04
先對火BFS一次,求出每個點的最小著火時間。再對人BFS一次,求出走到邊界的最少時間。#include <iostream>#include <queue>#include <cstring>using namespace std;int n,m,bz[1005][1005],qihuo[1005][1005];char map[1005][1005];int h[4][2]={-1,0,1,0,0,-1,0,1};struct point{int
Time of Update: 2018-12-04
高精度乘法,字串處理 #include <iostream> #include<iomanip> #include<cstring> using namespace std; int s; void chen(char a[],char b[])//a=a*b { int i,j,k,l,sum,c[410]={0}; l=strlen(a)+strlen(b); for(i=strlen(b)-1;i>=0
Time of Update: 2018-12-04
取得預存程序sp2的返回記錄,直接select into到暫存資料表: select * into #t from OPENROWSET('SQLOLEDB','SERVER=servername;uid=sa;pwd=123;Database=testdb','SET FMTONLY OFF;set nocount on;exec sp2 參數') as aselect * from #tdrop table #tselect * into #tfrom
Time of Update: 2018-12-04
題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=4416這個題目我感覺不好寫,各種出錯,最後參考這篇部落格的程式和思想才得以完成:http://hi.baidu.com/arosliu/item/ec421c23bf862ef951fd8769開始按照以前的尾碼數組的寫法,老是Run time error
Time of Update: 2018-12-04
題目連結:http://poj.org/problem?id=1228這個題目不好想,開始老是wa,後來不知道改了哪裡就AC了這個題目從範例可以看出給的凸包山的點不是按照順序來的,是隨便的一些點那麼我們就在這些點上建立凸包,那麼在建立凸包的時候我們不能隨便去掉邊也就是即使是可以去除的點也不能去掉,也就是傳統的graphm方法不能預先選擇結束之後要想這個凸包表示唯一那麼就不能在外部加任何一個點使其還能長成一個更大的凸包,這個就要求一個頂點與其前面兩個頂點或者後面兩個頂點至少有邊能共線,否則你就可以
Time of Update: 2018-12-04
題目連結:http://poj.org/problem?id=1861表示這個題目不想寫的,因為一看就是個最小產生樹問題,肯定能寫出來,後來想想這個英文題目看懂也不容易,就寫了吧以前寫最小產生樹都是用prim寫的,今天要還用prim就真沒意思了,換下克魯斯卡爾吧,正好複習下並查集,但是鬼知道題目給的範例竟然是錯的,鬱悶了一會後反正是Virtual judge,提交一下試試,過了!#include <iostream>#include <string.h>#include