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 1564
http://poj.org/problem?id=1564 /* @author: */ import java.util.Scanner; public class Main{ static int sum,n; static int arr[]=new int[20]; static int j,FLAG; static boolean used[]=new boolean[20]; static void f(int now,int total) { int i; if(total==sum) { FLAG=1; for(i=0;i< n;i++) if(used[i]) { System.out.printf("%d",arr[i]); break; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1562
http://poj.org/problem?id=1562 //* @author: 82638882@163.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); while(true) { int a=in.nextInt(); int b=in.nextInt(); if(a==0&&b==0)break; int count=0; int[][] arr=new int[a+2][b+2]; for(int i=1;i<=a;i++){ String s=in.next(); for(int j=1;j<=b;j++) arr[i][j]=s.charAt(j-1); } for(int … Continue reading
Posted in poj
Leave a comment
Poj Solution 1555
http://poj.org/problem?id=1555 //* @author: 82638882@163.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); while(in.hasNext()) { StringBuffer bb=new StringBuffer(); int[] a=new int[9]; boolean b=true; for(int i=0;i< 9;i++) a[i]=in.nextInt(); for(int i=0;i< 8;i++) { if(a[i]!=0) { if(b){ … Continue reading
Posted in poj
Leave a comment
Poj Solution 1552
http://poj.org/problem?id=1552 import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(true) { String temp = cin.nextLine(); if(temp.equals("-1")) break; temp = temp.substring(0, temp.length()-1).trim(); int[] num = new int[15]; String[] str = temp.split(" "); … Continue reading
Posted in poj
Leave a comment
Poj Solution 1548
http://poj.org/problem?id=1548 /* @author: */ import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int x[]=new int[1000], y[]=new int[1000]; boolean sign[]=new boolean[1000]; int a, b, n, m, i, ans; while( true ) { n … Continue reading
Posted in poj
Leave a comment
Poj Solution 1547
http://poj.org/problem?id=1547 import java.util.*; class Clay { private int l = 0; private int w = 0; private int h = 0; private String name; private int size = 0; public Clay(String l, String w, String h, String name) { this.l … Continue reading
Posted in poj
Leave a comment
Poj Solution 1546
http://poj.org/problem?id=1546 import java.io.*; import java.util.*; import java.math.*; /** * * @author gongshaoqing */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner cin=new … Continue reading
Posted in poj
Leave a comment
Poj Solution 1543
http://poj.org/problem?id=1543 //* @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=in.nextInt(); for(int i=6;i<=a;i++) { for(int j=2;j< a;j++) for(int m=j;m< a;m++) for(int n=m;n< a;n++) { if((n*n*n+m*m*m+j*j*j)==i*i*i) System.out.println("Cube = "+i+", Triple = … Continue reading
Posted in poj
Leave a comment
Poj Solution 1528
http://poj.org/problem?id=1528 //* @author: 82638882@163.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); System.out.println("PERFECTION OUTPUT"); while(true) { int a=in.nextInt(); if(a==0) break; double w=Math.sqrt(a); int total=1; for(int i=2;i< w;i++) { if(a%i==0) total+=(a/i+i); } if(a%w==0) total+=w; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1522
http://poj.org/problem?id=1522 /* @author:zeropinzuo */ import java.io.*; import java.util.*; public class Main{ static Scanner cin; static int count=0; public static void main(String args[]){ cin = new Scanner(System.in); int n; while((n=cin.nextInt())!=0) run(n); } static void run(int n){ Point start,end; start = new … Continue reading
Posted in poj
Leave a comment
Poj Solution 1521
http://poj.org/problem?id=1521 import java.io.BufferedReader; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.RoundingMode; /** * Accepted. * * * @author hong * */ public class Main { private static Node[] nodes = new Node[1000]; private static boolean[] used = new boolean[1000]; private static int … Continue reading
Posted in poj
Leave a comment
Poj Solution 1520
http://poj.org/problem?id=1520 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); while(true) { String s=in.nextLine(); if(s.equals("."))break; s=s.substring(0,s.length()-1); String[] arr=s.split(", "); int l=arr.length; int[] kk=new int[l]; ArrayList< Integer> arrI=new ArrayList< Integer>(); TreeMap< String,String> … Continue reading
Posted in poj
Leave a comment
Poj Solution 1519
http://poj.org/problem?id=1519 //* @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 number = in.next(); if (number.equals("0")) { break; } int len = number.length(); int sum = … Continue reading
Posted in poj
Leave a comment
Poj Solution 1517
http://poj.org/problem?id=1517 //* @author: 82638882@163.com public class Main { public static void main(String[] args) { int i, n, j; double e = 0; System.out.printf("n en- ———–n"); for (n = 0; n <= 9; ++n) { i = 1; for (j = … Continue reading
Posted in poj
Leave a comment
Poj Solution 1515
http://poj.org/problem?id=1515 #include <stdio.h> #include <memory.h> bool e[1000][1000]; int low[1000]; int visit[1000]; int vs,n; void print( int a, int b) { printf( "%d %dn", a+1, b+1 ); } void search( int s, int f ) { int i; visit[s] = vs++; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1511
http://poj.org/problem?id=1511 //* @author: 82638882@163.com import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static int[] cost; static node[] edge,redge; static int n; static boolean[] used; public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); … Continue reading
Posted in poj
Leave a comment
Poj Solution 1509
http://poj.org/problem?id=1509 /* @author: */ import java.util.Scanner; public class Main{ public static int minP(String s) { int i = 0, j = 1, k = 0; int l = s.length(); while (true) { if (i + k >= l || j … Continue reading
Posted in poj
Leave a comment
Poj Solution 1505
http://poj.org/problem?id=1505 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { static final int N = 500+10; static int n,m; static boolean flag[] = new boolean[N]; static long sum[] = new long[N],num[] = new long[N]; public static void main(String[]args) … Continue reading
Posted in poj
Leave a comment
Poj Solution 1504
http://poj.org/problem?id=1504 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(); String[] str = new String[2]; String rawA, rawB; int a, b, sum = 0; for(int i = 0; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1503
http://poj.org/problem?id=1503 import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigDecimal bd1 = BigDecimal.valueOf(0); BigDecimal bd2 = BigDecimal.valueOf(0); String str; while(cin.hasNext()) { str = cin.nextLine(); if(str.equals("0")) break; else { bd2 … Continue reading
Posted in poj
Leave a comment
Poj Solution 1496
http://poj.org/problem?id=1496 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); while(in.hasNext()) { String s=in.next(); boolean bb=true; for(int i=0;i< s.length()-1;i++) { if(s.charAt(i)-s.charAt(i+1)>=0) { System.out.println(0); bb=false; break; } } if(!bb)continue; int l=s.length(); long … Continue reading
Posted in poj
Leave a comment
Poj Solution 1493
http://poj.org/problem?id=1493 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { static final int N = 100000; static String str[] = new String[N]; static int n; static void start(){ for(int i=0;i< n;++i) str[i] = new String(); } public static … Continue reading
Posted in poj
Leave a comment
Poj Solution 1491
http://poj.org/problem?id=1491 //* @author ������<hongxp11@163.com> import java.text.DecimalFormat; import java.util.Scanner; import java.util.Vector; public class Main { public static int factor(int a, int b) { if (b == 0) return a; else return factor(b, a % b); } public static void main(String[] args) … Continue reading
Posted in poj
Leave a comment
Poj Solution 1488
http://poj.org/problem?id=1488 #include<stdio.h> int main() { char c; int q=1; while((c=getchar())!=EOF) { if(c == ‘"’) { printf(q ? "“":"”"); q=!q; } else printf("%c",c); } return 0; }
Posted in poj
Leave a comment
Poj Solution 1485
http://poj.org/problem?id=1485 #include <iostream> #define MAX 200000000 using namespace std; long r[300],sum[300][40],one[300][300]; long from[300][40],to[300][40],at[300][40]; long printDetail(long i, long j)//递归输出 { if(j<=0||i<=0) return 1; long num=printDetail(from[i][j]-1,j-1); cout<<"Depot "<<num<<" at restaurant "<<at[i][j]<<" serves ";; if(from[i][j]==to[i][j]) cout<<"restaurant "<<from[i][j]<<endl; else cout<<"restaurants "<<from[i][j]<<" to "<<to[i][j]<<endl; return … Continue reading
Posted in poj
Leave a comment
Poj Solution 1484
http://poj.org/problem?id=1484 //* @author: SmilingWang import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args){ int n, m, c; int i, j = 1, k; Scanner scanner = new Scanner(System.in); boolean blowFuse = false; int sumOfPower = 0; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1477
http://poj.org/problem?id=1477 //* @author: 82638882@163.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int c=0; while(true) { int a=in.nextInt(); if(a==0)break; c++; int[] arr=new int[a]; int total=0; for(int i=0;i< a;i++) { arr[i]=in.nextInt(); total+=arr[i]; } total/=a; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1476
http://poj.org/problem?id=1476 #include<stdio.h> #define debug 0 #define NMAX 20 #define DMAX 30 #define INF 1000000000 #define KMAX 1001 long d[KMAX][NMAX]; int main() { #if debug freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int T=1,N,K,i,j,k; long c[NMAX+1][NMAX+1][DMAX+1]; int t[NMAX+1][NMAX+1]; scanf("%d%d",&N,&K); while(N&&K) { for(i=1;i<=N;i++) for(j=1;j<=N;j++) { if(i!=j) … Continue reading
Posted in poj
Leave a comment
Poj Solution 1474
http://poj.org/problem?id=1474 #include<iostream> using namespace std; int xmin,ymin,xmax,ymax,n; int main() {int i,xn,yn,xp,yp,dx,dy,c_n=0; while(1) {cin>>n; if(!n)break; xmin=-32000;ymax=32000; xmax=-xmin;ymin=-ymax; cin>>xp>>yp; dx=xp;dy=yp; for(i=0;i<n;i++) {if(i<n-1)cin>>xn>>yn;else {xn=dx;yn=dy;} if(yn==yp){if(xn>xp){if(yp<ymax)ymax=yn;} else if(yp>ymin)ymin=yn; } else {if(yn>yp){if(xn>xmin)xmin=xn;} else if(xn<xmax)xmax=xn; } xp=xn;yp=yn; } cout<<"Floor #"<<++c_n<<endl; if(xmin<=xmax&&ymin<=ymax)cout<<"Surveillance is possible."<<endl<<endl; else cout<<"Surveillance is … Continue reading
Posted in poj
Leave a comment
Poj Solution 1473
http://poj.org/problem?id=1473 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<string.h> #include<math.h> #define sq2 0.70710678118654752440084436210485 #define INF 30000 #define NMAX 52 int p[10]={0}; int as[10]={0}; double xd[8]={0,sq2,1,sq2,0,-sq2,-1,-sq2}; double yd[8]={1,sq2,0,-sq2,-1,-sq2,0,sq2}; double cx,cy; void findpos(char *s) { s[strlen(s)-1]=0; int len; char direct[4]; sscanf(s,"%d%s",&len,direct); int d; if(!strcmp("NE",direct)) d=1; else … Continue reading
Posted in poj
Leave a comment
Poj Solution 1472
http://poj.org/problem?id=1472 /* @author: */ import java.io.BufferedInputStream; import java.util.Scanner; import java.util.Arrays; class Main { public static Scanner cin=new Scanner(new BufferedInputStream(System.in)); public static int [] coef=new int[11]; public static String temp; public static void work(int con,int expo) { while (true) { temp=cin.next(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 1471
http://poj.org/problem?id=1471 #include<iostream> #include<stdlib.h> #include<stdio.h> using namespace std; #define MAXNO 102 int tr[MAXNO][2*MAXNO-1]={0}; int maxtr[MAXNO][2*MAXNO-1]={0}; int curmax=0; int min(int a,int b) { if(a>b) return b; else return a; } int sum(int a1,int an,int n) { return (a1+an)*n/2; } int ln(int n) … Continue reading
Posted in poj
Leave a comment
Poj Solution 1468
http://poj.org/problem?id=1468 //* @author mekarlos@gmail.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=0,k=0; boolean band; int M[][]=new int[5000][4]; while(scan.hasNext()){ n=scan.nextInt(); for(int i=0;i< n;i++){ for(int j=0;j< 4;j++){ M[i][j]=scan.nextInt(); } } k=0; for(int i=0;i< … Continue reading
Posted in poj
Leave a comment
Poj Solution 1466
http://poj.org/problem?id=1466 import java.util.*; /** * * @author yeming */ public class Main { static int n; static LinkedList< Integer>[] matrix; static int[] result; static boolean[] state; static int ans; /** * @param args the command line arguments */ public static … Continue reading
Posted in poj
Leave a comment
Poj Solution 1465
http://poj.org/problem?id=1465 //* @author: 82638882@163.com import java.io.*; import java.util.*; public class Main { static int[] p,q; static int m,n; static Queue< mye> qu; public static void main(String[] args) throws IOException { Scanner in=new Scanner(System.in); qu=new LinkedList< mye>(); while(in.hasNext()) { qu.clear(); n=in.nextInt(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 1463
http://poj.org/problem?id=1463 #include <stdio.h> #include <memory.h> #define min(a,b) ((a)<(b)?(a):(b)) int e[2000][20]; int en[2000]; int ans[2000][2], n; void calc( int k, int f ) { int i; ans[k][0] = 0, ans[k][1] = 1; for( i=0; i<en[k]; i++ ) { if( e[k][i] != … Continue reading
Posted in poj
Leave a comment
Poj Solution 1458
http://poj.org/problem?id=1458 import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); while(in.hasNext()){ String str1 = in.next(); String str2 = in.next(); int[][] DP = new int[str1.length()+1][str2.length()+1]; int i; for(i=0;i<=str1.length();i++) DP[i][0] = 0; for(i=0;i<=str2.length();i++) DP[0][i] = 0; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1455
http://poj.org/problem?id=1455 //* @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=in.nextInt(); while((a–)!=0) { int b=in.nextInt(); int ans=0; int c=b/2; if(b%2==0) ans=c*(c-1); else ans=c*c; System.out.println(ans); } } }
Posted in poj
Leave a comment
Poj Solution 1450
http://poj.org/problem?id=1450 #include <stdio.h> #include <stdlib.h> #define DEBUG 0 int main(void) { int iCase; if(DEBUG) freopen("in","r",stdin); scanf("%d",&iCase); int number; for ( number = 1; number <=iCase; ++number) { int N,M; scanf("%d%d",&M,&N); printf("Scenario #%d:n",number); printf("%d.",M*N); if(M%2&&N%2)printf("41"); else printf("00"); printf("nn"); } return 0; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1430
http://poj.org/problem?id=1430 #include<iostream> using namespace std; const long big=1024*1024*1024; long b; long n,m; char a[16][34]={ ". . . . . . . . . . . . . . . 1", ". . . . . . . . . . … Continue reading
Posted in poj
Leave a comment
Poj Solution 1426
http://poj.org/problem?id=1426 //* @author mekarlos@gmail.com import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; public class Main { public static void main(String[] args) throws IOException { BigInteger a; BigInteger b; BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in)); long c=0,d=0; long n=0; while((n=Long.parseLong(stdin.readLine()))!=0){ //for(n=1;n<=200;n++) { b=new … Continue reading
Posted in poj
Leave a comment
Poj Solution 1423
http://poj.org/problem?id=1423 import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int n = cin.nextInt(); while(n > 0) { int test = cin.nextInt(); if(test <= 3) System.out.println(1); else { double result = 0.5*Math.log10(2*test*Math.PI)+ … Continue reading
Posted in poj
Leave a comment
Poj Solution 1422
http://poj.org/problem?id=1422 //* @author: import java.io.*; import java.util.*; import java.math.*; public class Main { static int n,m,match[]=new int[201]; static boolean mat[][]=new boolean[201][201],v[]=new boolean[201]; static boolean findmatch(int pre) { int i; for(i=0;i< m;i++) { if(mat[pre][i]&&!v[i]) { v[i]=true; int buf=match[i]; match[i]=pre; if(buf==-1||findmatch(buf))return true; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1419
http://poj.org/problem?id=1419 /* @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 1418
http://poj.org/problem?id=1418 #include<iostream> #include"math.h" using namespace std; #define MSIZE 1000 const double pi=3.14159265358979324; const double eps=1e-15; struct point {double x,y;}; struct typearc {double a,b;}; struct typecir {point ct; double r; typearc arc[360]; int n; }; int cmp(double a,double b) {if(fabs(a-b)<eps)return 0; … Continue reading
Posted in poj
Leave a comment
Poj Solution 1416
http://poj.org/problem?id=1416 /* @author: */ import java.util.*; public class Main { private int target; private char num[]; private int max; private StringBuffer s; private StringBuffer result; boolean check; public Main(int target,char num[]){ this.target=target; this.num=num; max=0; s=new StringBuffer(""); result=new StringBuffer(""); } public … Continue reading
Posted in poj
Leave a comment
Poj Solution 1411
http://poj.org/problem?id=1411 import java.util.*; /** * * @author leo */ public class Main { /** * @param args the command line arguments */ public static boolean prime(int n) { for (int i = 2; i * i <= n; i++) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 1410
http://poj.org/problem?id=1410 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=scanner.nextInt(); double dx1,dx2,dy1,dy2; double x1,x2,y1,y2; double k,b; double d1,d2,d3,d4; for (int i=0;i<n ;i++ ){ x1=scanner.nextDouble(); y1=scanner.nextDouble(); x2=scanner.nextDouble(); y2=scanner.nextDouble(); dx1=scanner.nextDouble(); dy1=scanner.nextDouble(); dx2=scanner.nextDouble(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 1408
http://poj.org/problem?id=1408 /* @author:����acmilan_fan@yahoo.cn */ import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { static double[][][] mesh=new double[32][32][2]; public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s; String[] ss; int n,i,j; double max=0d,t; while((s=br.readLine())!=null&&!"0".equals(s)){ n=parseInt(s); s=br.readLine(); … Continue reading
Posted in poj
Leave a comment