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 2241
http://poj.org/problem?id=2241 import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { Scanner cin = new Scanner(System.in); int kase = 0; while (true) { int n … Continue reading
Posted in poj
Leave a comment
Poj Solution 2240
http://poj.org/problem?id=2240 import java.util.*; public class Main { static int c=0; static String[] str; static double[][] map; static double[] v; static int n,m; static boolean[] visited; public static void main(String[] args){ Main p=new Main(); Scanner cin=new Scanner(System.in); while(true){ c++; n=cin.nextInt(); if(n==0) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2239
http://poj.org/problem?id=2239 //* @author: import java.io.*; import java.util.*; public class Main{ static boolean[][] g=new boolean[305][100]; static int[] xm=new int[305]; static int[] ym=new int[100]; static boolean[] chk=new boolean[100]; static int un,vn; public static boolean search(int u){ int v; for(v=0;v< vn;v++){ if(g[u][v]&&!chk[v]){ chk[v]=true; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2236
http://poj.org/problem?id=2236 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int a=in.nextInt(); int max=in.nextInt(); max*=max; int[] ax=new int[a+1]; int[] ay=new int[a+1]; int[] arr=new int[a+1]; int[] bool=new int[a+1]; for(int i=1;i<=a;i++) arr[i]=i; for(int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2234
http://poj.org/problem?id=2234 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(true) { int n = cin.nextInt(); int i = 0; int[] a = new int[n]; while(n > 0) { a[i++] = cin.nextInt(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2231
http://poj.org/problem?id=2231 import java.io.BufferedInputStream; import java.math.BigInteger; import java.util.Arrays; import java.util.Scanner; public class Main { public static BigInteger getVolume(int[] a, int n) { BigInteger sum = new BigInteger("0"); BigInteger s = new BigInteger("0"); int i = 0; for (; i < n … Continue reading
Posted in poj
Leave a comment
Poj Solution 2229
http://poj.org/problem?id=2229 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int[] arr=new int[1000001]; arr[1]=1; arr[2]=2; for(int i=3;i< 1000001;i++) { if(i%2==0) arr[i]=(arr[i-2]+arr[i/2])%1000000000; else arr[i]=arr[i-1]; } int a=in.nextInt(); System.out.println(arr[a]); } }
Posted in poj
Leave a comment
Poj Solution 2228
http://poj.org/problem?id=2228 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ static int maxs=Integer.MAX_VALUE/3; int f[][][]=new int[2][3831][2]; int g[][][]=new int[2][3831][2]; int a[]=new int[3831]; int n,m; int maxv(int x,int y){ return x>y?x:y; } void dp(){ int pre=0,cur=1; for(int i=0;i<=m;i++) f[1][i][0]=f[1][i][1]=g[1][i][0]=g[1][i][1]=-maxs; f[1][0][0]=f[1][1][1]=0; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2218
http://poj.org/problem?id=2218 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; class WHO implements Comparable{ String name; int index; public int compareTo(Object temp){ WHO tmp = (WHO)temp; if(tmp.index< this.index) return -1; return 1; } } public class Main { static final int N … Continue reading
Posted in poj
Leave a comment
Poj Solution 2215
http://poj.org/problem?id=2215 //* @author: import java.io.*; import java.util.*; public class Main { static int SZ=1005; public static void main(String[] args) throws Exception { int r,c,q; int sum; int i,j,x1,y1,x2,y2; int[][] area=new int[SZ][SZ]; for(i=0;i< SZ;++i) area[i][0]=0; Scanner cin=new Scanner(System.in); int T=cin.nextInt(); while(–T>=0) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2209
http://poj.org/problem?id=2209 //* @author ������<hongxp11@163.com> import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int numOfSon = in.nextInt(); int power = in.nextInt(); int[] potential = new int[numOfSon]; int sum = 0; if(power%2==1) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2208
http://poj.org/problem?id=2208 //* @author: import java.util.*; public class Main { static double area( double l1, double l2, double l3 ) { double p = ( l1 + l2 + l3 ) / 2; return Math.sqrt( p * (p-l1) * (p-l2) * … Continue reading
Posted in poj
Leave a comment
Poj Solution 2196
http://poj.org/problem?id=2196 //* @author popop0p0popo public class Main{ public static void main(String[] args){ int t,h,w; for (int i=2992;i< 10000 ;i++ ){ t=getI(i); h=getD(Integer.toHexString(i)); w=getD(Integer.toString(i,12)); if (t==h&&h==w){ System.out.println(i); } } } public static int getD(String n){ int d=0; for (int i=0;i< n.length() … Continue reading
Posted in poj
Leave a comment
Poj Solution 2195
http://poj.org/problem?id=2195 #include <vector> using namespace std; typedef int type; //�������� const int size = 210; //ͼ�Ķ���ģ const type MAX_FEE = 10000000; //�������� const int MAX = 1000; //������� class minfee_flow { public: //ɾ�����б� void clear(); //���һ���from��to ����Ϊc ��λ������Ϊw �ı� void … Continue reading
Posted in poj
Leave a comment
Poj Solution 2193
http://poj.org/problem?id=2193 //* @author: import java.util.*; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); long dp[][]=new long[11][2010]; int nn=sc.nextInt(); for (int i=1;i<=2000;i++) dp[1][i]=1; for (int i=2;i<=10;i++) for (int j=i;j<=2000;j++) for (int k=1;k<=j/2;k++) dp[i][j]+=dp[i-1][k]; for (int ii=1;ii<=nn;ii++) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2192
http://poj.org/problem?id=2192 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main{ public static void main(String[] args) throws Exception{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); for(int a=1;a<=n;a++){ String strTemp = in.readLine(); StringTokenizer toke = new StringTokenizer(strTemp); String str1 … Continue reading
Posted in poj
Leave a comment
Poj Solution 2191
http://poj.org/problem?id=2191 //* @author popop0p0popo import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ String[] store={"23 * 89 = 2047 = ( 2 ^ 11 ) – 1", "47 * 178481 = 8388607 = ( 2 ^ 23 … Continue reading
Posted in poj
Leave a comment
Poj Solution 2190
http://poj.org/problem?id=2190 //* @author: 82638882@163.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); String a=in.next(); int t=0; int n=-1; for(int i=0;i< 10;i++) { char c=a.charAt(i); if(c!=’?’&&c!=’X’){ t+=(c-‘0′)*(10-i); } else if(c==’X’) t+=10; else if(c==’?’) n=10-i; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2189
http://poj.org/problem?id=2189 #include <stdio.h> #include <algorithm> #include <memory.h> using namespace std; int n,p,c; int s[1001]; int main() { int i, j, k; scanf( "%d %d %d", &n, &p, &c ); memset( s, 0, sizeof( s ) ); for( i=0; i<n; i++ … Continue reading
Posted in poj
Leave a comment
Poj Solution 2188
http://poj.org/problem?id=2188 //* @author: 82638882@163.com import java.io.*; public class Main{ static long ans=0; 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()); ans=0; int[] arr=new int[a]; int[] aww=new int[a]; for(int i=0;i< a;i++) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2187
http://poj.org/problem?id=2187 #include"stdio.h" #include"math.h" #include<vector> #include<algorithm> using namespace std; //////////////////////////////// typedef int Type;/*????????*/ //////////////////////////////// //???????? struct point { Type x,y; point(){x=y=0;} point(Type x,Type y):x(x),y(y){;} bool operator==(point &a){return x==a.x&&y==a.y;} }; //???? inline Type cheng(point a,point b,point c) {return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);} inline Type cheng(point … Continue reading
Posted in poj
Leave a comment
Poj Solution 2186
http://poj.org/problem?id=2186 //PKU_2186_Popular Cows_ǿlͨ��_���(kosaraju) #include <iostream> using namespace std; struct Point { int Index; Point *Next; Point(int index = 0) { Index = index; Next = NULL; } }; struct HeadPoint { Point *List; Point *LastPoint; HeadPoint() { List = NULL; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2185
http://poj.org/problem?id=2185 #include <stdio.h> char map[10000][80]; int n,m; bool sign[75][10000]; int main() { int i, j, n, m, k, h, l; bool key; scanf( "%d %d", &n, &m ); for( i=0; i<n; i++ ) scanf( "%s", map[i] ); for( k=1; k<m; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2184
http://poj.org/problem?id=2184 #include <stdio.h> #include <memory.h> #include <algorithm> #include <functional> using namespace std; bool mem[200100],*sign = mem+100000; int mem2[200100],*ans = mem2+100000; typedef pair<int,int> node; node c[100]; int n; node mem3[2][100000],*s = mem3[0], *t = mem3[1]; int sn,tn; int main() { int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2183
http://poj.org/problem?id=2183 //* @author: <strong> import java.util.*; public class Main { private int t; private int b[]; public Main(int t){ this.t=t; b=new int[1000000]; } private void doIt(){ int st=0; while(true){ t/=10; t%=10000;//ȡt���м���λ t*=t;//ƽ�� t%=1000000;//ȡt�ĺ���λ if (b[t]!=0){//���t���ֹ�,����ѭ���� st++; System.out.println(t+" "+(st-b[t])+" "+st);//ѭ���ڵĵ�һ����ѭ���ڴ�С����Ҫ���η���ѭ���� break; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2182
http://poj.org/problem?id=2182 /* @author: */ import java.util.Scanner; public class Main{ public static void main(String args[]) { int p[]=new int[8010]; int q[]=new int[8080]; int n,k; Scanner sc=new Scanner(System.in); n=sc.nextInt(); p[0]=0; for(int i=1;i< n;i++) { k=sc.nextInt(); for(int j=i;j>k;j–) p[j]=p[j-1]; p[k]=i; } for(int i=0;i< … Continue reading
Posted in poj
Leave a comment
Poj Solution 2181
http://poj.org/problem?id=2181 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int a=in.nextInt(); boolean flag=true; int sum=0; int[] arr=new int[a+1]; for(int i=0;i< a;i++) arr[i]=in.nextInt(); for(int i=0;i< a;i++) { if(flag) { if(arr[i]>arr[i+1]) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2175
http://poj.org/problem?id=2175 #include <memory.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #define y1 yy1 const int size = 210; int dis[size][size], n, m; int x1[100], y1[100], x2[100], y2[100]; int s2[100], lim2[100]; int f[100][100]; inline int distance( int i, int j ) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2173
http://poj.org/problem?id=2173 #include <stdio.h> #include <memory.h> #include <algorithm> using namespace std; typedef pair<int,int> point; int w, h, n; int a[110], x[110], y[110], m; point p[110]; void init( ) { int i, xx, yy; m = 0; n = 0; scanf( "%d … Continue reading
Posted in poj
Leave a comment
Poj Solution 2172
http://poj.org/problem?id=2172 /* @author: */ import java.util.Scanner; public class Main { static final double EPS =1e-7; //����x*y �ܷ���� a*b �� static boolean canfit( double a, double b, double x, double y ) { double t; double l=Math.sqrt(x*x+y*y),ll=x*x+y*y; if(x*x+y*y – a*a-b*b > … Continue reading
Posted in poj
Leave a comment
Poj Solution 2163
http://poj.org/problem?id=2163 //* @author: import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int m=sc.nextInt(); int n=sc.nextInt(); int k=sc.nextInt(); node a[]=new node[k+1]; for(int i=0;i<=k;i++) a[i]=new node(); for (int i=1;i<=k;i++) { a[i].p=sc.nextDouble(); a[i].pm=a[i-1].pm+a[i].p; a[i].pn=a[i-1].pn+a[i].p; if … Continue reading
Posted in poj
Leave a comment
Poj Solution 2159
http://poj.org/problem?id=2159 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { public static void main(String[] args) throws Exception { BufferedReader read = new BufferedReader(new InputStreamReader( System.in)); String chips = null; String source; boolean flg; while ((chips … Continue reading
Posted in poj
Leave a comment
Poj Solution 2155
http://poj.org/problem?id=2155 import java.util.Scanner; public class Main { private static int[][] matrix = new int[1001][1001]; private static int n; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int testNum = sc.nextInt(); for (int i = 0; i < … Continue reading
Posted in poj
Leave a comment
Poj Solution 2153
http://poj.org/problem?id=2153 //* @author: 82638882@163.com import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int[] arr=new int[n]; HashMap< String,Integer> hs=new HashMap< String,Integer>(); String s=in.nextLine(); int tag=-1; for(int i=0;i< n;i++) { s=in.nextLine(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2141
http://poj.org/problem?id=2141 //* @author popop0p0popo import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ Scanner scanner=new Scanner(new BufferedReader(new InputStreamReader(System.in))); String code=scanner.nextLine(); String sent=scanner.nextLine(); String decode=""; for (int i=0;i< sent.length() ;i++ ){ decode=decode+getChar(sent.charAt(i),code); } System.out.print(decode); } public static char … Continue reading
Posted in poj
Leave a comment
Poj Solution 2140
http://poj.org/problem?id=2140 import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(cin.hasNext()) { int num = cin.nextInt(); int ways = 1; int index = num/2+1; for(int i = index; i > 1; i–) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2138
http://poj.org/problem?id=2138 #include <iostream> #include <string> #include <vector> #include <cstring> #include <algorithm> using namespace std; int D; string ori; string v[1005]; int l[1005]; int longgest; bool visited[1005]; vector<string> vre; void search(string &str,int z) { bool Find = false; visited[z] = true; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2137
http://poj.org/problem?id=2137 #include <iostream> #include <cmath> #include <cstdio> using namespace std; int map[2][50][202]; int len[202]; int N; int S; double calc(double x1,double y1,double x2,double y2) { return sqrt((x1 – x2) * (x1 – x2) + (y1 – y2) * (y1 – … Continue reading
Posted in poj
Leave a comment
Poj Solution 2135
http://poj.org/problem?id=2135 #include<iostream> #include"stdio.h" #include"vector" using namespace std; struct edge { int from; int to; int len; int opp; }; vector<edge> e[1010]; int from[1010],dis[1010],n,m; bool sign[1010]; edge *along[1010]; void dijstra() { int i,j,k,to; for(i=0;i<n;i++) { sign[i]=0; dis[i]=999999999; } sign[0]=0; from[0]=-1; dis[0]=0; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2133
http://poj.org/problem?id=2133 #include<iostream> using namespace std; long a[140000],s[140000]; int main() { long i,n,m,j;long result; long begin[200],st,k,ss; char c; while(1) { cin>>m>>n; if(cin.fail())break; long h; h=(1<<16); result=0; for(j=0;j<m;j++) { cin>>c; result*=2; result+=c-‘0’; } for(i=0;i<n;i++) { begin[i]=0; for(j=0;j<m;j++) { cin>>c; begin[i]*=2; begin[i]+=c-‘0’; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 2132
http://poj.org/problem?id=2132 //* @author:alpc12 import java.io.*; import java.util.*; import java.math.*; public class Main { static int N = 26; int n; int M; int[][] adj = new int[26][26]; boolean[] chk = new boolean[26]; boolean DFS(int K, int m) { chk[m] = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2127
http://poj.org/problem?id=2127 /* @author: */ import java.util.*; public class Main { static int ans[][], xf[][], yf[][]; static int as[][], len[]; static public void main( String [] str ) throws Exception{ Scanner cin = new Scanner(System.in); int n = cin.nextInt(), m; int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2126
http://poj.org/problem?id=2126 //* @author popop0p0popo import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ Scanner scanner=new Scanner(new BufferedReader(new InputStreamReader(System.in))); int n=Integer.parseInt(scanner.nextLine()); if (n< 2){ System.out.println("YES"); } else if (n==2){ int a=scanner.nextInt(); int b=scanner.nextInt(); int c=scanner.nextInt(); if (b*b-4*a*c>=0){ System.out.println("NO"); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2121
http://poj.org/problem?id=2121 //* @author: 82638882@163.com import java.io.*; import java.util.*; public class Main { static String[] Num=new String[]{ "zero","one","two","three","four","five","six","seven","eight","nine","ten", "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen", "nineteen","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety", "hundred","thousand","million" }; public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); String s; while(true) { s=in.readLine(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2114
http://poj.org/problem?id=2114 #include <vector> #include <stdio.h> #include <algorithm> using namespace std; typedef pair< int, int > edge; vector< edge > e[10010]; int v[10010],s[10010]; int st[10010],sn; bool sign[10010]; int n; int find_root_search( int r, int f ) { int temp,i,j; v[r] = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2112
http://poj.org/problem?id=2112 #include<iostream> using namespace std; #define null 0 const int size=1010; long dis[size][size],k,m,c,up,w[size][size]; int maxmatch(int n,int m,long w[][size],int *p) { int p_n[size]; int p_m[size]; bool sign[size]; int q[size],from[size],s,t; int i,j,link,now,h; for(i=0;i<n;i++)p_n[i]=-1; for(j=0;j<m;j++)p_m[j]=-1; for(i=0;i<n;i++) if(p_n[i]==-1) { for(j=0;j<m;j++)sign[j]=0; s=1;link=-1; from[0]=-1; q[0]=size-1; p_m[size-1]=i; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2109
http://poj.org/problem?id=2109 import java.math.BigInteger; import java.util.Scanner; public class Main { static final BigInteger TWO = new BigInteger("2"); static final BigInteger ONE = BigInteger.ONE; public static void main(String[] args) { Scanner in = new Scanner(System.in); // k^n=p findK; BigInteger p; int n; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2105
http://poj.org/problem?id=2105 import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int num = Integer.valueOf(cin.nextLine()).intValue(); for(int i = 0; i < num; i++) { String str, temp; int a,b,c,d = 0; StringBuffer sb … Continue reading
Posted in poj
Leave a comment
Poj Solution 2104
http://poj.org/problem?id=2104 //* @author: 82638882@163.com import java.io.*; import java.util.Arrays; class Main { public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); String[] ss=in.readLine().split(" "); int a=Integer.parseInt(ss[0]); int k=Integer.parseInt(ss[1]); my[] p=new my[a]; ss=in.readLine().split(" "); for(int i=0;i< a;i++) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2103
http://poj.org/problem?id=2103 //* @author: import java.math.BigInteger; import java.util.Scanner; public class Main { static int oneNum[] = new int[65536]; static BigInteger arr[] = new BigInteger[20]; static int n; static BigInteger list[] = new BigInteger[65536]; public static void main(String[] args) { for(int i … Continue reading
Posted in poj
Leave a comment