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 2362
http://poj.org/problem?id=2362 import java.io.*; import java.util.*; public class Main { //记录数字的总长度。 int totalNum; //记录各个数字的值的数组。 int[] numArr; //记录每个小短棒是否被使用过。 boolean[] used; public static void main(String args[]) throws Exception { Main m=new Main(); m.begin(); } private void begin() throws Exception { Scanner cin = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2361
http://poj.org/problem?id=2361 /* @author: */ import java.util.Scanner; public class Main{ public static void main(String args[]) { char cc[][]=new char[3][3]; Scanner sc=new Scanner(System.in); int n,i,j; n=sc.nextInt(); while((n–)!=0) { for(i=0;i< 3;i++) cc[i]=sc.next().toCharArray(); int x=0,o=0; boolean xw=false,ow=false; boolean bb=true; for(i=0;i< 3;i++) for(j=0;j< 3;j++) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2353
http://poj.org/problem?id=2353 #include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #define NMAX 501 #define INF 2000000001 long m[NMAX][NMAX]={0}; long a[NMAX][NMAX]={0}; long M,N; long b[NMAX*NMAX]={0}; int xp[3]={-1,0,1},yp[3]={0,-1,0}; void solve() { int i,j; for(i=1;i<=N;i++) { m[1][i]=a[1][i]; } for(i=2;i<=M;i++) { for(j=1;j<=N;j++) { if(m[i][j]>a[i][j]+m[i-1][j]) m[i][j]=a[i][j]+m[i-1][j]; } for(j=2;j<=N;j++) { if(m[i][j]>a[i][j]+m[i][j-1]) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2352
http://poj.org/problem?id=2352 import java.io.*; public class Main { static int[] star=new int[32002]; static int[] lev=new int[15000]; 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 n=a; while((a–)!=0) { String[] ss=in.readLine().split(" "); int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2350
http://poj.org/problem?id=2350 import java.util.Scanner; /** * poj2350 easy * @author NC */ 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 < … Continue reading
Posted in poj
Leave a comment
Poj Solution 2349
http://poj.org/problem?id=2349 //* @author: 82638882@163.com import java.io.*; import java.util.Arrays; public class Main { static int[] p; public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int n=Integer.parseInt(in.readLine()); while((n–)!=0) { String[] ss=in.readLine().split(" "); int a=Integer.parseInt(ss[0]); int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2348
http://poj.org/problem?id=2348 /* @author: */ import java.util.Scanner; public class Main{ static boolean judge(int x,int y) { int t; if(x< y) {t=x;x=y;y=t;} if(x%y==0) return true; if(x-y< y) return !judge(y,x-y); return true; } public static void main(String args[]) { Scanner sc=new Scanner(System.in); int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2346
http://poj.org/problem?id=2346 import java.util.*; /** * * @author leo */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, max=0; int[][] dp = new int[6][46]; for(int i=0;i<=9;i++){ dp[1][i]=1; } for(int i=1;i<=5;i++){ dp[i][0]=1; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 2344
http://poj.org/problem?id=2344 #include"stdio.h" #include"algorithm" #include"math.h" using namespace std; int n,m; const double eps=1e-8; const int size=2000; double a[size][size]; bool sign[size]; void swap_c(int k,int l) { int i; for(i=0;i<m;i++) std::swap(a[i][k],a[i][l]); } bool guass() { int i,j,k,l;double temp; for(i=0;i<m;i++) sign[i]=1; for(l=0,i=0;i<n;i++) { while(fabs(a[l][i])<eps) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2339
http://poj.org/problem?id=2339 //* @author ������<hongxp11@163.com> import java.util.Scanner; public class Main { /** * @param args */ public static int row; public static int column; public static int replace(int i, int j, int[][] array) { int temp = 0; if (array[i][j] == … Continue reading
Posted in poj
Leave a comment
Poj Solution 2336
http://poj.org/problem?id=2336 //* @author ������<hongxp11@163.com> import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int num = in.nextInt(); for(int i = 0; i< num; i++) { int n = in.nextInt(); int t = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2333
http://poj.org/problem?id=2333 #include <stdio.h> const int size = 5010; struct point { int x, y; }p[size], pt[size]; __int64 s[size]; inline __int64 cross( point &o, point &a, point &b ) { return (__int64)(a.x-o.x)*(b.y-o.y) – (__int64)(a.y-o.y)*(b.x-o.x); } inline __int64 dis( point &a, point … Continue reading
Posted in poj
Leave a comment
Poj Solution 2328
http://poj.org/problem?id=2328 import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); List guess = new ArrayList(); List response = new ArrayList(); while(cin.hasNext()) { String guessNum = cin.nextLine(); if(guessNum.equals("0")) break; String result = cin.nextLine(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2325
http://poj.org/problem?id=2325 //* @author import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { BigInteger n,zero,ten; int count,flag,a[],i,j; a=new int[2000]; Scanner cin = new Scanner(System.in); while(cin.hasNext()) { n = cin.nextBigInteger(); zero=BigInteger.ZERO; ten=BigInteger.TEN; if(n.compareTo(BigInteger.valueOf(-1))==0) break; if(n.compareTo(ten)< … Continue reading
Posted in poj
Leave a comment
Poj Solution 2323
http://poj.org/problem?id=2323 //* @author:alpc12 import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.math.BigInteger; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { new Main().run(); } BigInteger [][] dp; private void run() throws FileNotFoundException { Scanner … Continue reading
Posted in poj
Leave a comment
Poj Solution 2318
http://poj.org/problem?id=2318 /* @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); while(run() != false) ; } static boolean run(){ int n = cin.nextInt(); if(n==0) return false; Box box … Continue reading
Posted in poj
Leave a comment
Poj Solution 2316
http://poj.org/problem?id=2316 //* @author: 82638882@163.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int[] a=new int[300]; int k=0; while(in.hasNextInt()) { String s=in.next(); for(int i=0;i< s.length();i++) a[i]=(a[i]+s.charAt(i)-‘0’)%10; k=s.length(); } for(int i=0;i< k;i++) { System.out.print(a[i]); } … Continue reading
Posted in poj
Leave a comment
Poj Solution 2313
http://poj.org/problem?id=2313 //* @author: import java.util.*; public class Main { static long abs(long a) { if(a< 0) return -a; else return a; } static boolean in(long a,long b,long c) { if(abs(a-c)+abs(b-c)==abs(a-b)) return true; else return false; } static public void main( … Continue reading
Posted in poj
Leave a comment
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