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

Category Archives: poj
Poj Solution 2312
http://poj.org/problem?id=2312 /* @author: */ import java.util.Scanner; public class Main{ public static void main(String args[]) { Scanner sc=new Scanner(System.in); int p[][]=new int[305][305]; char c[][]=new char[305][305]; int n,m,i,j,k; while(sc.hasNext()) { n=sc.nextInt(); m=sc.nextInt(); if(m==0&&n==0) break; for(i=0;i< n;i++) c[i]=sc.next().toCharArray(); int x1=0,y1=0,x2=0,y2=0; for(i=0;i< n;i++) for(j=0;j< … Continue reading
Posted in poj
Leave a comment
Poj Solution 2309
http://poj.org/problem?id=2309 //* @author mekarlos@gmail.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan=new Scanner(System.in); long n=scan.nextInt(); long k=0,j,v,temp,l,r; for(int i=0;i< n;i++){ k=scan.nextInt(); if(k%2==1)System.out.println(k+" "+k); else{ j=(int)Math.floor(Math.log(k)/Math.log(2)); v=1<< j; while(v!=k){ j–; if(v>k)v-=(1<< j); else v+=(1<< j); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2305
http://poj.org/problem?id=2305 import java.io.BufferedInputStream; import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); while (scan.hasNext()) { int b = scan.nextInt(); if (b == 0) { break; } BigInteger p = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2304
http://poj.org/problem?id=2304 //* @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 begin = in.nextInt(); int one … Continue reading
Posted in poj
Leave a comment
Poj Solution 2302
http://poj.org/problem?id=2302 /* @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 n = cin.nextInt(); for(int i=0;i< n;i++) run(); } static void run(){ Card card = new Card(cin); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2301
http://poj.org/problem?id=2301 import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); if (scan.hasNext()) { int n = scan.nextInt(); for (int i = 0; i < n; i++) { int s = scan.nextInt(); int d … Continue reading
Posted in poj
Leave a comment
Poj Solution 2299
http://poj.org/problem?id=2299 import java.io.BufferedInputStream; import java.util.Scanner; public class Main { static long num = 0; public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); while (scan.hasNext()) { int n = scan.nextInt(); if (n == 0) { break; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 2295
http://poj.org/problem?id=2295 //* @author popop0p0popo import java.util.*; import java.io.*; public class Main{ public static void main(String[] args) throws Exception{ BufferedReader scanner=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(scanner.readLine()); String f; String[] t; double a1,a2,b1,b2; for (int i=0;i< n ;i++ ){ a1=0; a2=0; b1=0; b2=0; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2291
http://poj.org/problem?id=2291 //* @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 t=scanner.nextInt(); int n,max; int[] r; for (int i=0;i< t ;i++ ){ n=scanner.nextInt(); r=new int[n]; for (int j=0;j< n … Continue reading
Posted in poj
Leave a comment
Poj Solution 2287
http://poj.org/problem?id=2287 // author:M.J import java.text.DecimalFormat; import java.util.*; import java.util.concurrent.CountDownLatch; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); int[] t = new int[1002]; int[] king = new int[1002]; int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2284
http://poj.org/problem?id=2284 #include"algorithm" #include"math.h" #include<iostream> #include"set" using namespace std; struct point { double x,y; }; struct line { point a,b; }; typedef double Type; inline bool equal(point a,point b) { return a.x==b.x&&a.y==b.y; } //////////////////////////////////////////////// inline Type cheng(point a,point b,point c) {return … Continue reading
Posted in poj
Leave a comment
Poj Solution 2282
http://poj.org/problem?id=2282 /* @author: */ import java.util.*; /** * * @author Leo */ public class Main { /** * @param args the command line arguments */ public static void recurse(int [] digit,int n,int count){ if(n<=0) return; int oneNo=n%10,tenNo; int m=n/10; tenNo=m; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2280
http://poj.org/problem?id=2280 #include"algorithm" #include"math.h" #include<iostream> using namespace std; double const pi=3.1415926535898; struct point { double x,y; int r; enum {up,down}side; double th; }p[1010],ptemp[1010]; int n; //degree //from n-1 to j double theta(int j) { return atan2(p[j].y-p[n-1].y,p[j].x-p[n-1].x); } bool cmp(point a,point b) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2279
http://poj.org/problem?id=2279 //* @author: ccQ.SuperSupper import java.math.*; import java.util.*; public class Main { /** * @param args */ public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub BigInteger num ,b;//= new BigInteger; num=BigInteger.valueOf(1); Scanner cin = new Scanner(System.in); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2273
http://poj.org/problem?id=2273 //* @author ������<hongxp11@163.com> import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(true) { String input = in.nextLine(); if(input.equals("R0C0")) break; int index = 0; while(input.charAt(index)!=’C’) { index++; } int num = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2272
http://poj.org/problem?id=2272 import java.util.*; /** * * @author Leo */ public class Main { /** * @param args the command line arguments */ public static int score(double x,double y){ double r=x*x+y*y; if(r<=9.) return 100; if(r<=36.) return 80; if(r<=81.) return 60; if(r<=144.) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2263
http://poj.org/problem?id=2263 //* @author: 82638882@163.com import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static int[][] w=new int[256][256]; public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int cnt=0; while(true) { cnt++; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2262
http://poj.org/problem?id=2262 import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=1; while(true){ n=sc.nextInt(); if(n==0) break; test(n); } } /* * 8 = 3 + 5 * 20 = 3 + 17 * 42 = 5 … Continue reading
Posted in poj
Leave a comment
Poj Solution 2260
http://poj.org/problem?id=2260 //* @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 n = in.nextInt(); if (n … Continue reading
Posted in poj
Leave a comment
Poj Solution 2257
http://poj.org/problem?id=2257 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static String[] names = new String[0]; static int[] amount = new int[0]; private static int[][] relation = new int[0][0]; private static int getIndex(String s) { for (int i = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2256
http://poj.org/problem?id=2256 import java.io.BufferedReader; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.RoundingMode; public class Main { /** * Parse the value. * @param s the given string such as 4.5A, 2.5MW * @return */ private static double parseValue(String s) { int i = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2255
http://poj.org/problem?id=2255 import java.util.Scanner; public class Main { private static char[] seq = new char[100]; private static int s = -1; public static void getPostOrder(String pre, String in) { if (pre.length() == 1 && in.length() == 1) { seq[++s] = in.charAt(0); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2253
http://poj.org/problem?id=2253 //* @author //import java.io.File; //import java.io.FileNotFoundException; //import java.util.Arrays; import java.util.Scanner; public class Main{ Scanner cin = new Scanner(System.in); int n; int cases; int stone[][]; double map[][]; public void inPut() { //File f = new File("D:\ACM\POJ����\2253\test.txt"); // cin = new … Continue reading
Posted in poj
Leave a comment
Poj Solution 2251
http://poj.org/problem?id=2251 //* @author: import java.util.*; class point { int x; int y; int z; int step; public point(int x,int y,int z,int step){ this.x=x; this.y=y; this.z=z; this.step=step; } public int getX(){ return this.x; } public int getY(){ return this.y; } public … Continue reading
Posted in poj
Leave a comment
Poj Solution 2250
http://poj.org/problem?id=2250 import java.io.BufferedInputStream; import java.util.Scanner; public class Main{ private static final int MAXLEN = 101; private static int[][] c = new int[MAXLEN][MAXLEN]; private static int[][] b = new int[MAXLEN][MAXLEN]; public static void main(String[] args) { Scanner scan = new Scanner(new … Continue reading
Posted in poj
Leave a comment
Poj Solution 2249
http://poj.org/problem?id=2249 //* @author mekarlos@gmail.com import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static long[][] M=new long[2000][2000]; public static long comb(int n,int k){ if(k>(n/2))k=n-k; if(n< 2000&&k< 2000) return M[n][k]; else if(k==n||k==0) return 1; else if(k==1) return n; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2248
http://poj.org/problem?id=2248 /* @author: */ import java.util.Scanner; public class Main{ static int arr[]=new int[20]; static int n,minn; static int save[]=new int[20]; static void bfs(int a) { int i,j; if(a>=minn)return; if(arr[a-1]==n) { if(a< minn){ minn=a; for(i=0;i< a;i++) save[i]=arr[i]; } return; } for(i=a-1;i>=0;i–) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2247
http://poj.org/problem?id=2247 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { TreeSet< Integer> t=new TreeSet< Integer>(); for(int i=0;i< 50;i++) { if(Math.pow(2, i)>2000000000) break; for(int j=0;;j++) { int ans2=(int)(Math.pow(2, i)*Math.pow(3, j)); if(ans2>2000000000) break; for(int k=0;;k++) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2245
http://poj.org/problem?id=2245 //* @author: 82638882@163.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int count=0; while(true) { count++; if(count!=1) System.out.println(); int a=in.nextInt(); if(a==0) break; int[] b=new int[a]; for(int i=0;i< a;i++) b[i]=in.nextInt(); for(int a1=0;a1< a-5;a1++) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2244
http://poj.org/problem?id=2244 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); while(true) { int n=in.nextInt(); if(n==0)break; int i,j,m=1; while(true) { i=0; j=n-1; while(j!=0) { i=(i+m-1)%j; j–; if(i==0) break; } if(j==0) { System.out.println(m); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2243
http://poj.org/problem?id=2243 import java.util.*; public class Main { private static int[][] position = new int[8][2]; private static int[][] chessboard = new int[8][8]; public Main() { initPosition(); } /** * ��ʼ��������ߵķ��� */ private static void initPosition() { position[0][0] = -2; position[0][1] = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2242
http://poj.org/problem?id=2242 //* @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))); double[] x,y; double k1,k2,b1,b2,ox,oy; double r; while (scanner.hasNext()){ x=new double[3]; y=new double[3]; for (int i=0;i< 3 ;i++ ){ x[i]=scanner.nextDouble(); … Continue reading
Posted in poj
Leave a comment
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