Meta
-
Recent Posts
Recent Comments
Archives
- May 2024
- April 2023
- February 2023
- January 2023
- December 2022
- November 2022
- September 2022
- June 2022
- July 2021
- January 2021
- February 2020
- September 2019
- March 2018
- February 2018
- August 2016
- July 2016
- June 2016
- May 2016
- April 2016
- March 2016
- February 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- August 2015
- July 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- April 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- September 2013
- August 2013
- July 2013
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
Categories
Author Archives: toad, die
Poj Solution 1716
http://poj.org/problem?id=1716 //* @author: 82638882@163.com import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int a=Integer.parseInt(in.readLine()); int ans=2,i; my[] arr=new my[a]; String[] ss; for(i=0;i< a;i++) { ss=in.readLine().split(" … Continue reading
Posted in poj
Leave a comment
Poj Solution 1715
http://poj.org/problem?id=1715 #include <stdio.h> #include <algorithm> using namespace std; char *digit = "FEDCBA9876543210"; //0123456789ABCDEF"; int p[8][8]; bool sign[16]; int main() { int i,j,n,k; char ans[9]; for( k=0; k<8; k++ ) { p[k][7-k] = 1; for( i=6-k; i>=0; i– ) p[k][i] = … Continue reading
Posted in poj
Leave a comment
Poj Solution 1714
http://poj.org/problem?id=1714 #include <stdio.h> #include <algorithm> using namespace std; struct node { int id; int order; node *l,*r,*f; int lv,rv,fv; }tree[600]; node *leaf[600]; int n, k; int e[600][3]; int v[600][3]; int d[600]; inline bool isleaf( node *s ) { return s->id … Continue reading
Posted in poj
Leave a comment
Poj Solution 1710
http://poj.org/problem?id=1710 #include<iostream> #include"memory.h" using namespace std; int n; bool map[101][101]; void init() {int i,j;bool k; k=1; for(i=1;i<=n;i++,k=!k) map[i][1]=k; for(i=1;i<=n;i++) for(j=2;j<=n;j++) map[i][j]=!map[i][j-1]; } void doit() {int i,j,step=2*n+1;bool k=true; for(i=1;i<n;i++) {cout<<step; for(j=1;j<=n;j++) if(map[i][j]==k)cout<<‘ ‘<<(i-1)*n+j; cout<<endl; step+=2;k=!k; cout<<step; for(j=1;j<=n;j++) if(map[i][j]==k)cout<<‘ ‘<<(i-1)*n+j; cout<<endl; step+=2;k=!k; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1709
http://poj.org/problem?id=1709 #include<iostream> #include"memory.h" #include"string.h" using namespace std; char word[1000][23]; int index[27]; int n,l,len[1000],set[1000]; void init() { int i; for(i=0;i<26;i++)index[i]=n; for(i=0;i<n;i++) { cin>>word[i]; len[i]=strlen(word[i]); if(index[word[i][0]-‘a’]==n)index[word[i][0]-‘a’]=i; } memset(set,1,1000*sizeof(int)); } char best[100];int go; char w[100]; void find(int a,int b) { if(go&&strcmp(w,best)>0)return; if(b==a&&a) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 1708
http://poj.org/problem?id=1708 #include<iostream> #include"memory.h" using namespace std; int set[100][100]; int map[100][10000][2]; int path[100]; int n,l,k,q; int cir[100]; void init() {int i,m,a,b; memset(path,0,100*sizeof(int)); memset(set,0,100*100*sizeof(int)); cin>>n>>l>>k>>q; l–;k–;q–; for(i=0;i<n;i++)cin>>cir[i]; cin>>m; for(i=0;i<m;i++){cin>>a>>b;a–;b–; cin>>map[a][path[a]++][1]; map[a][path[a]-1][0]=b;} } int queue[10000][3],head,tail; void find() {int a,b,c,i,to; head=0;tail=0; queue[tail][0]=l;queue[tail][1]=k; queue[tail][2]=0; set[l][k]=set[k][l]=1; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1707
http://poj.org/problem?id=1707 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; import java.math.*; import java.text.*; public class Main { static class com { BigInteger a,b;//a/b… com add(com C) { com ret=new com(); BigInteger lcm; lcm=b.multiply(C.b).divide(b.gcd(C.b)); ret.b=lcm; ret.a=a.multiply(lcm.divide(b)).add(C.a.multiply(lcm.divide(C.b))); lcm=ret.b.gcd(ret.a); ret.a=ret.a.divide(lcm); ret.b=ret.b.divide(lcm); return ret; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 1706
http://poj.org/problem?id=1706 //* @author: <strong>Yeming Hu</strong>"cslittleye@gmail.com" import java.util.*; import java.io.*; public class Main { public static Map< Integer,Integer> mapOldToNew; public static Map< Integer,Integer> mapNewToOld; public static int counter = 1; public static void main(String[] args) throws Exception { BufferedReader stdin = new … Continue reading
Posted in poj
Leave a comment
Poj Solution 1704
http://poj.org/problem?id=1704 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ public static void main(String args[] ){ int arr[]=new int[10005]; Scanner sc=new Scanner(System.in); int T=sc.nextInt(); while((T–)!=0){ int n=sc.nextInt(); arr[0] = 0; for (int i = 1; i <= n;i++) arr[i]=sc.nextInt(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 1703
http://poj.org/problem?id=1703 //* @author: 82638882@163.com import java.io.*; public class Main { static int[] p,q; static int u; public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int a=Integer.parseInt(in.readLine()); while((a–)!=0) { String[] ss=in.readLine().split(" "); int n=Integer.parseInt(ss[0]); int … Continue reading
Posted in poj
Leave a comment
Poj Solution 1702
http://poj.org/problem?id=1702 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ static long ans[]={ 1,3,9,27,81,243,729,2187,6561,19683,59049,177147,531441, 1594323,4782969,14348907,43046721,129140163,387420489,1162261467 }; public static void main(String args[]){ int n; Scanner sc=new Scanner(System.in); n=sc.nextInt(); int p[]=new int[25]; while((n–)!=0){ Arrays.fill(p,0); int a; a=sc.nextInt(); int len=0,i; while(a!=0) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 1700
http://poj.org/problem?id=1700 import java.util.Arrays; import java.util.Scanner; public class Main { private static int sum; public static int getSumTime(int[] a, int n) { if (n < 3) { return a[n-1]; } else if (n == 3) { return a[0] + a[1] + … Continue reading
Posted in poj
Leave a comment
Poj Solution 1699
http://poj.org/problem?id=1699 #include<iostream> #include"string.h" #include<vector> #include<algorithm> using namespace std; int m[10][10]; int set[10]; int len[10];int n; int order1[10][9],order2[10][9]; char word[10][22]; int h; int cmp1(int a,int b) {return m[h][a]>m[h][b];} int cmp2(int a,int b) {return m[a][h]>m[b][h];} int link(int a,int b) {int i,j; for(i=0;i<=len[a];i++) … Continue reading
Posted in poj
Leave a comment
Poj Solution 1695
http://poj.org/problem?id=1695 /* @author:zeropinzuo */ import java.io.*; import java.util.*; public class Main{ static Scanner cin; public static void main(String args[]){ cin = new Scanner(System.in); int M = cin.nextInt(); for(int i=0;i< M;i++) run(); } static void run(){ int N = cin.nextInt(); int[][] … Continue reading
Posted in poj
Leave a comment
Poj Solution 1694
http://poj.org/problem?id=1694 #include<iostream> #include<vector> #include"stdlib.h" using namespace std; int child[201],need[201]; int ch[201][200]; //int cmp(int i,int j) int cmp(const void * i,const void * j) { if(need[*((int *)i)]<need[*((int *)j)]) return 1; else if(need[*((int *)i)]>need[*((int *)j)]) return -1; return 0; } void doit(int … Continue reading
Posted in poj
Leave a comment
Poj Solution 1693
http://poj.org/problem?id=1693 #include<iostream> using namespace std; char set[100][100]; int n_cl,n_rl; struct line {int x1,x2,y1,y2;}; line c[100],r[100]; inline int min(int a,int b) {if(a<b)return a; else return b; } inline int max(int a,int b) {if(a>b)return a; else return b; } int jiao(line rl,line … Continue reading
Posted in poj
Leave a comment
Poj Solution 1692
http://poj.org/problem?id=1692 #include<iostream> using namespace std; int links[101][101]; int f[101],s[101],n,m; int answer; void find() {int i,j,t,k,h; links[0][0]=0; links[0][1]=0; links[1][0]=0; for(i=1;i<=n;i++) for(j=1;j<=m;j++) {t=links[i-1][j]>links[i][j-1]?links[i-1][j]:links[i][j-1]; if(f[i]!=s[j]) { for(k=i-1;k>=1;k–) if(f[k]==s[j])break; for(h=j-1;h>=1;h–) if(f[i]==s[h])break; if(k&&h&&links[k-1][h-1]+1>t)t=links[k-1][h-1]+1; } links[i][j]=t; } } int main() {int i,t; cin>>t; while(t–) {cin>>n>>m; for(i=1;i<=n;i++)cin>>f[i]; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1689
http://poj.org/problem?id=1689 #include<iostream> #include"vector" #include"algorithm" #define max(x,y) (((x)>(y))?(x):(y)) #define min(x,y) (((x)<(y))?(x):(y)) using namespace std; struct point {long x,y;}; struct type_dbx {int n; point d[50]; }; type_dbx dbx[50]; vector <long> x,y; long mx,my; int n; char sign[50*50*2]; inline long cheng(point a,point b,point … Continue reading
Posted in poj
Leave a comment
Poj Solution 1687
http://poj.org/problem?id=1687 #include<iostream> #include"math.h" using namespace std; long x[50],y[50]; inline long cheng(int a,int b,int c) {return (x[a]-x[b])*(y[a]-y[c])-(x[a]-x[c])*(y[a]-y[b]);} int main() {int t,n,m,p[50],h,key,i,j,l;char s[50];long an,anb; cin>>t; for(;t>0;t–) {cin>>n; for(i=0;i<n;i++) cin>>x[i]>>y[i]; cin>>m;key=0;anb=0; for(l=0;l<m;l++) {cin>>h; for(i=0;i<h;i++){cin>>p[i];p[i]–;} an=0; for(i=1;i<h-1;i++) { an+=cheng(p[0],p[i],p[i+1]); } // cout<<":::"<<an<<endl; if(abs(an)>anb){anb=abs(an);key=l+1; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 1686
http://poj.org/problem?id=1686 //* @author: import java.util.Scanner; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class Main{ ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); Scanner cin=new Scanner(System.in); int[] num=new int[60]; void init() { for(int i=1;i< 59;i++) num[i]=i+9997; } void solve() throws … Continue reading
Posted in poj
Leave a comment
Poj Solution 1685
http://poj.org/problem?id=1685 #include<iostream> #include"math.h" #include"stdio.h" using namespace std; double x[60][2],y[60][2],xs,ys,xt,yt; double best1[62][2],best2[62][2],len[62]; int color[60],cl,c[62]; inline double jl(double a,double c,double b,double d) {return sqrt((a-b)*(a-b)+(c-d)*(c-d));} int main() {int t,i,j,k,n;double ss,tt; cin>>t; for(;t>0;t–) {cin>>xs>>ys>>xt>>yt; cin>>cl; for(i=0;i<cl;i++)cin>>color[i]; cin>>n; for(i=0;i<n;i++){cin>>x[i][0]>>y[i][0]>>x[i][1]>>y[i][1]>>c[i]; len[i]=jl(x[i][0],y[i][0],x[i][1],y[i][1]);} for(i=0;i<n;i++) if(c[i]==color[0]){best1[i][0]=jl(xs,ys,x[i][0],y[i][0])+len[i]; best1[i][1]=jl(xs,ys,x[i][1],y[i][1])+len[i];} else best1[i][0]=best1[i][1]=999999999999; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1683
http://poj.org/problem?id=1683 #include<iostream> using namespace std; int h[50][8],n,m; char obj[8][8]; int sign[50][50]; int alive[50]; int can(int i,int j) {int k; for(k=0;k<n;k++) if(h[i][k]*h[j][k]>0)break; if(k==n)return 1; else return 0; } void merage(int a,int b) {int i; for(i=0;i<n;i++)h[a][i]+=h[b][i]; for(i=0;i<n*m;i++){sign[a][i]+=sign[b][i];sign[i][a]+=sign[i][b];} alive[b]=-a; } int main() {int … Continue reading
Posted in poj
Leave a comment
Poj Solution 1681
http://poj.org/problem?id=1681 //* @author: import java.util.*; public class Main { static Scanner in = new Scanner(System.in); static char[][] board;//���ڱ����ʼ״̬ static boolean[][] map;//ǽ�ڵ�״̬ static int cnt;//Ϳ��Ĵ��� static void click(int x, int y) {//Ϳ��x,y)���ĸ��� ++cnt; map[x][y] = !map[x][y]; if(x-1>=0) map[x-1][y] = !map[x-1][y];//����ĸ��� if(y-1>=0) … Continue reading
Posted in poj
Leave a comment
Poj Solution 1679
http://poj.org/problem?id=1679 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; class Edge{ int u,v,disten; void set(int u,int v,int disten){ this.u = u; this.v = v; this.disten = disten; } } interface MST{ int N = 100+2,BIG = 1000000000; int getMST(int op); } … Continue reading
Posted in poj
Leave a comment
Poj Solution 1677
http://poj.org/problem?id=1677 //* @author /** * pku 1677 Girls’ Day * Memory: 3524K Time: 172MS * Language: Java Result: Accepted * @Author conanhjj */ import java.util.*; public class Main { static Scanner in = new Scanner(System.in); static int g,w; static String[] … Continue reading
Posted in poj
Leave a comment
Poj Solution 1676
http://poj.org/problem?id=1676 //* @author: 82638882@163.com import java.io.*; public class Main { public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int a=Integer.parseInt(in.readLine()); int[] N=new int[]{ 119,36,93,109,46,107,123,37,127,111}; while((a–)!=0) { int[] Num1=new int[4]; int[] Num2=new int[4]; String line=in.readLine(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 1675
http://poj.org/problem?id=1675 /* @author:����acmilan_fan@yahoo.cn */ import java.io.*; public class Main { static double A = Math.PI*2/3; public static void main(String[] args)throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); String[] ss; int num = Integer.parseInt(s); int x1, y1, … Continue reading
Posted in poj
Leave a comment
Poj Solution 1674
http://poj.org/problem?id=1674 //* @author: 82638882@163.com import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); String[] ss; int a=Integer.parseInt(in.readLine()); HashSet< Integer> hs=new HashSet< Integer>(); while((a–)!=0) { int b=Integer.parseInt(in.readLine()); ss=in.readLine().split(" … Continue reading
Posted in poj
Leave a comment
Poj Solution 1671
http://poj.org/problem?id=1671 import java.util.*; public class Main{ static double dp[][]=new double[51][51]; static { dp[1][1]=1; for (int i=2;i<=50;i++) for(int j=1;j<=50;j++) dp[i][j]=dp[i-1][j-1]+dp[i-1][j]*j; } public static void main(String args[]){ Scanner sc=new Scanner(System.in); while (sc.hasNext()) { int n=sc.nextInt(); if(n==0) break; double ans=0; for (int i=1;i<=n;i++) … Continue reading
Posted in poj
Leave a comment
Poj Solution 1666
http://poj.org/problem?id=1666 //* @author ������<hongxp11@163.com> import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); while (true) { int student = in.nextInt(); if (0 … Continue reading
Posted in poj
Leave a comment
Poj Solution 1664
http://poj.org/problem?id=1664 import java.io.BufferedInputStream; import java.util.Scanner; /** * *poj1664 * f(m, n) = f(m-n, n) + f(m, n-1) * f(m, n): ��m��ƻ��ŵ�n�������еķ����� * f(m, n-1): ��m��ƻ��ŵ�n-1�������еķ�����(����������һ�������) * f(m-n, n): ��m��ƻ��ŵ�n��������,����ÿ�������ж���ƻ��(����n���4,��m-n��ź���,Ȼ��ÿ�����ӷ�һ��) * @author NC */ public class Main { public static void … Continue reading
Posted in poj
Leave a comment
Poj Solution 1663
http://poj.org/problem?id=1663 //* @author mekarlos@gmail.com import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in)); int n=new Integer(stdin.readLine()); StringTokenizer tokens; int x,y; for(int i=0;i< n;i++){ tokens=new StringTokenizer(stdin.readLine()); … Continue reading
Posted in poj
Leave a comment
Poj Solution 1661
http://poj.org/problem?id=1661 import java.util.Arrays; import java.util.Scanner; /** * POJ1661 * @author Bruce * */ class Board implements Comparable<Board>{ int lx; int rx; int h; public Board(int x,int y,int h){ this.lx = x; this.rx = y; this.h = h; } public int … Continue reading
Posted in poj
Leave a comment
Poj Solution 1659
http://poj.org/problem?id=1659 //* @author: 82638882@163.com import java.io.*; import java.util.*; public class Main { static int[][] p; static ri[] arr; public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int n=Integer.parseInt(in.readLine()); while((n–)!=0) { int m=Integer.parseInt(in.readLine()); p=new int[m][m]; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1658
http://poj.org/problem?id=1658 //* @author ������<hongxp11@163.com> import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); for(int i = 0; i < n; i++) { int one = in.nextInt(); int two … Continue reading
Posted in poj
Leave a comment
Poj Solution 1657
http://poj.org/problem?id=1657 #include <stdio.h> #include <math.h> int main() { int t; scanf("%d", &t); char c1, c2; int x1, y1, x2, y2; int w, h, c, x; while (t–) { getchar(); scanf("%c%d %c%d", &c1, &y1, &c2, &y2); x1 = c1 – ‘a’ … Continue reading
Posted in poj
Leave a comment
Poj Solution 1656
http://poj.org/problem?id=1656 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int num = in.nextInt(); int[][] grids = new int[101][101]; for(int i = 0; i< num; i++) { String color = in.next(); int … Continue reading
Posted in poj
Leave a comment
Poj Solution 1655
http://poj.org/problem?id=1655 #include<iostream> using namespace std; typedef struct edge {int a; struct edge *p; }edge; edge *a[21000]; int s[21000]; int b[21000]; int f[21000]; int fr[21000]; int go; void find(int from,int to) {edge *p; p=a[to];fr[to]=from; while(p) {if(p->a==from){p=p->p;continue;} find(to,p->a);p=p->p; } f[go–]=to; } int … Continue reading
Posted in poj
Leave a comment
Poj Solution 1654
http://poj.org/problem?id=1654 /* @author: */ import java.util.*; public class Main { static long get_Area(long x1,long y1, long x2,long y2) { return x1*y2-x2*y1; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); int move[][]={{0,0},{1,-1},{1,0},{1,1},{0,-1},{0,0},{0,1},{-1,-1},{-1,0},{-1,1}}; int d,ncase; long x0,y0,newx,newy,area; ncase=sc.nextInt(); String … Continue reading
Posted in poj
Leave a comment
Poj Solution 1651
http://poj.org/problem?id=1651 //* @author: 82638882@163.com import java.io.*; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int a=Integer.parseInt(in.readLine()); int[] arr=new int[a]; String[] ss=in.readLine().split(" "); for(int i=0;i< a;i++) arr[i]=Integer.parseInt(ss[i]); int[][] gra=new int[a][a]; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1650
http://poj.org/problem?id=1650 /* @author: */ import java.util.Scanner; public class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); double a; int d; a=sc.nextDouble(); d=sc.nextInt(); double ans; double min=a; int v1=0,v2=0,m=1,n=1; while(m<=d&&n<=d) { ans=m*1.0/n*1.0; if(ans>=a) { if(min>ans-a) { min=ans-a; v1=m; v2=n; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 1648
http://poj.org/problem?id=1648 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<string.h> #include<math.h> #define INF 30000 #define NMAX 13 float N,E,W; double gety(double x) { return (E-W)/N*x+W; } void solve() { int i,j; int sum=0; double(y); for(i=0;i<N;i++) { for(j=0;j<N;j++) { for(int p=0;p<2;p++) { y=gety(i+p); if(y>=j&&y<=j+1) { sum++; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1639
http://poj.org/problem?id=1639 //* @author import java.util.*; import java.io.*; import java.util.concurrent.*; public class Main { private static class UFSets { UFSets(int l) { s = new int[l]; for(int i=0; i!=l; ++i) s[i] = i; } void union(int x, int y) { s[find(x)] … Continue reading
Posted in poj
Leave a comment
Poj Solution 1637
http://poj.org/problem?id=1637 //* @author import java.util.*; import java.util.concurrent.ArrayBlockingQueue; public class Main { static int N = 205; static int [] degin, degout, deg, pre; static int [][] cap; private static int maxflow(int s, int t, int size) { Queue<Integer> que = … Continue reading
Posted in poj
Leave a comment
Poj Solution 1633
http://poj.org/problem?id=1633 //* @author:alpc12 import java.math.BigInteger; import java.util.Scanner; public class Main { BigInteger[][] dp = new BigInteger[51][51]; BigInteger go(int n, int y) { if (y == 1) return BigInteger.ONE; if (n < y || y < 1) return BigInteger.ZERO; if(dp[n][y] != … Continue reading
Posted in poj
Leave a comment
Poj Solution 1631
http://poj.org/problem?id=1631 #include <stdio.h> #include <algorithm> using namespace std; int a[40000], n; int ans[40000]; int id[40000], m; bool cmp( int s1,int s2 ) { return a[s1] < a[s2]; } int main() { int i, j, s; int cas; scanf( "%d", &cas … Continue reading
Posted in poj
Leave a comment
Poj Solution 1630
http://poj.org/problem?id=1630 #include<iostream> using namespace std; struct point {int x,y;}; long cheng(point a,point b,point c) {return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);} long dcheng(point a,point b,point c) {return (b.x-a.x)*(c.x-a.x)+(b.y-a.y)+(c.y-a.y);} point p[10000]; int n,k[32],begin[32],end[32],m; void init() {int i,h=0;char c; cin>>n; for(i=0;i<=n;i++) {begin[i]=h; while(cin.peek()!=’#’) {cin>>p[h].x>>c; cin>>p[h++].y>>c; } cin.get(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 1628
http://poj.org/problem?id=1628 #include <stdio.h> #include <algorithm> using namespace std; __int64 p[210],q[210]; inline int geti( char c ) { if( c <= ‘Z’ && c >= ‘A’ ) return c – ‘A’ + 26; else return c – ‘a’; } int n, … Continue reading
Posted in poj
Leave a comment
Poj Solution 1617
http://poj.org/problem?id=1617 /* @author:����acmilan_fan@yahoo.cn */ import java.io.*; import java.util.*; public class Main { public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s; String ciphertext; int codesize; int textrow; int colnum; StringBuilder sb; while((s=br.readLine())!=null&&!s.equals("THEEND")){ //length of the … Continue reading
Posted in poj
Leave a comment
Poj Solution 1615
http://poj.org/problem?id=1615 #include"iostream" #include"stdlib.h" #include"memory.h" //#include"time.h" using namespace std; long m[5][100],len[5],n,total,answer; /////////////////////////// long cas; /////////////////////////// void init() { n=5;total=0; int i,j; for(i=0;i<n;i++) { len[i]=80; for(j=0;j<len[i];j++) { m[i][j]=rand()%201-100; total+=m[i][j]; } } } void init1() { n=0;total=0; do { len[n]=0; do { cin>>m[n][len[n]++]; … Continue reading
Posted in poj
Leave a comment