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 2574
http://poj.org/problem?id=2574 #include<iostream> #include"stdio.h" #include"math.h" #include"algorithm" using namespace std; ////////////////////////////// #define Type double /*????????*/ ////////////////////////////// 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);} struct line {point a,b; line(){;} … Continue reading
Posted in poj
Leave a comment
Poj Solution 2573
http://poj.org/problem?id=2573 //* @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(); ArrayList< Integer> t=new ArrayList< Integer>(); for(int i=0;i< a;i++) t.add(in.nextInt()); if(a==1){ System.out.println(t.get(0)); System.out.println(t.get(0)); } else{ int total=0; Collections.sort(t); ArrayList< Integer> … Continue reading
Posted in poj
Leave a comment
Poj Solution 2572
http://poj.org/problem?id=2572 //* @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.next(); String[] s1=s.split("\+"); String[] s2=s1[1].split("\="); StringBuffer b1=new StringBuffer(s1[0]); StringBuffer b2=new StringBuffer(s2[0]); StringBuffer b3=new StringBuffer(s2[1]); b1=b1.reverse(); b2=b2.reverse(); b3=b3.reverse(); int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2571
http://poj.org/problem?id=2571 //* @author: import java.util.*; import static java.lang.Math.*; public class Main { static double a, b, c; static double[] change( double th,double fi, double l) { double z = l * sin( th/180*PI ); double y = l * cos( … Continue reading
Posted in poj
Leave a comment
Poj Solution 2570
http://poj.org/problem?id=2570 //* @author: 82638882@163.com import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static int[][] m=new int[201][201]; public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); while(true) { int n=Integer.parseInt(in.readLine()); if(n==0)break; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2569
http://poj.org/problem?id=2569 //* @author: 82638882@163.com import java.io.*; import java.util.*; import java.util.Map.Entry; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); HashMap< String,Integer> ts=new HashMap< String,Integer>(); while(true) { int a=Integer.parseInt(in.readLine()); if(a==0)break; String … Continue reading
Posted in poj
Leave a comment
Poj Solution 2568
http://poj.org/problem?id=2568 #include<iostream> #include"stdio.h" #include"stdlib.h" #include"memory.h" using namespace std; bool e[51][51]; bool s[51]; int a[51],n; void print( int f ) { int i; printf( "(%d", f ); for( i=1; i<=n; i++ ) if( e[f][i] ) { printf( " " ); print( … Continue reading
Posted in poj
Leave a comment
Poj Solution 2567
http://poj.org/problem?id=2567 #include"stdio.h" #include"stdlib.h" #include"memory.h" int d[51],n; bool e[51][51]; void creat( int f ) { int s; char t[10]; scanf( "%[ ,0-9]", t ); s = atoi( t ); if( s > n ) n = s; if( f ) e[f][s] … Continue reading
Posted in poj
Leave a comment
Poj Solution 2566
http://poj.org/problem?id=2566 #include"stdio.h" #include"algorithm" #include"math.h" using namespace std; int sum[100010]; int *id[100010]; const bool cmp( int *a, int *b ) { return *a<*b; } int main() { int n,m,i,t,j,a,b,ans,temp,k; while( 1 ) { scanf( "%d %d", &n, &m ); if( n … Continue reading
Posted in poj
Leave a comment
Poj Solution 2565
http://poj.org/problem?id=2565 //* @author mekarlos@gmail.com import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub Scanner scan=new Scanner(System.in); BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tokens; tokens=new … Continue reading
Posted in poj
Leave a comment
Poj Solution 2564
http://poj.org/problem?id=2564 #include "stdio.h" #include "string.h" #include "vector" using namespace std; const int size = 25000; vector< char* > s1[18][26]; vector< char* > s2[18][26]; char w[size][17]; int ans[size],len[size]; bool check( char *a, char *b ) { int la = len[ ( … Continue reading
Posted in poj
Leave a comment
Poj Solution 2563
http://poj.org/problem?id=2563 #include<iostream> using namespace std; int d=0,m=0; inline void data(long g) {cout<<g/10000<<"-"; g%=10000;if(g/1000==0)cout<<‘0’; cout<<g/100<<"-"; g%=100;if(g/10==0)cout<<‘0’; cout<<g<<‘ ‘; } inline void demerit() {cout<<d<<" demerit point(s)."<<endl;} inline void merit() {cout<<m<<" merit point(s)."<<endl;} inline void none() {cout<<"No merit or demerit points."<<endl;} int main() … Continue reading
Posted in poj
Leave a comment
Poj Solution 2562
http://poj.org/problem?id=2562 //* @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 first = in.next(); String second = in.next(); //System.out.println(first.length()+" "+second.length()); if(first.equals("0") && second.equals("0")) { break; } int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2560
http://poj.org/problem?id=2560 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ static double INF=99999999.0; public static void main(String args[]) { Scanner sc=new Scanner(System.in); double p[][]=new double[101][101]; double ax[]=new double[101]; double ay[]=new double[101]; double dis[]=new double[101]; boolean used[]=new boolean[101]; int n,i,j; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2559
http://poj.org/problem?id=2559 //* @author: 82638882@163.com import java.io.*; public class Main { static int[] p,b,c; static int a; public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); while(true) { String[] ss=in.readLine().split(" "); a=Integer.parseInt(ss[0]); if(a==0) break; p=new int[a+2]; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2557
http://poj.org/problem?id=2557 #include<iostream> #include"string.h" using namespace std; int width[210],n; int ans[210][210]; char fold[210]; bool init() { int i,j; cin>>fold; if(cin.fail())return 0; n=strlen(fold); for(i=0;i<n;i++) { for(j=1;i+j<n&&i-j>=0&&fold[i+j]+fold[i-j]==’A’+’V’;j++) ; width[i]=j; } return 1; } inline int get_ans(int a,int b) { return (a>b)?0:ans[a][b]; } void … Continue reading
Posted in poj
Leave a comment
Poj Solution 2556
http://poj.org/problem?id=2556 //* @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(); System.out.println("300 420 moveto"); System.out.println("310 420 lineto"); int b=0; int x=310; int y=420; for(int i=0;i< s.length();i++) { char … Continue reading
Posted in poj
Leave a comment
Poj Solution 2555
http://poj.org/problem?id=2555 /* @author:zeropinzuo */ import java.io.*; import java.util.*; import java.text.DecimalFormat; public class Main{ static Scanner cin; static double ci = 2.09, cw = 4.19; static double em = 335; public static void main(String args[]){ cin = new Scanner(System.in); while(run()) ; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2553
http://poj.org/problem?id=2553 #include"stdio.h" #include"memory.h" #include"list" using namespace std; long sign[5010]; long st[5010],s; long ok[5010]; long v; list<int> out[5000],in[5000]; void find(int a) {list<int>::iterator iter; sign[a]=1; for(iter=out[a].begin();iter!=out[a].end();iter++) { if(sign[*iter]==0)find(*iter); } st[s++]=a; } int sink; void find_too(int a) {list<int>::iterator iter; sign[a]=sink; for(iter=in[a].begin();iter!=in[a].end();iter++) { if(sign[*iter]!=0&&sign[*iter]!=sink)ok[sign[*iter]]=1; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2552
http://poj.org/problem?id=2552 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { ArrayList< Integer> a=new ArrayList< Integer>(); for(int i=2;i< 35000;i++) a.add(i); int count=0; while(count< a.size()) { for(int i=count+a.get(count);i< a.size();i+=a.get(count)) a.set(i, 0); for(int i=0;i< a.size();i++) if(a.get(i)==0){ a.remove(i); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2551
http://poj.org/problem?id=2551 //* @author ������<hongxp11@163.com> import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()) { int input = in.nextInt(); int result = 1; int begin = 1; while(true) { if(begin % input … Continue reading
Posted in poj
Leave a comment
Poj Solution 2549
http://poj.org/problem?id=2549 import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.Set; /** * Accepted. * * @author Administrator * */ public class Main { private static Set< Long> set = new HashSet< Long>(); private … Continue reading
Posted in poj
Leave a comment
Poj Solution 2546
http://poj.org/problem?id=2546 //* @author: ccQ.SuperSupper import java.io.*; import java.text.DecimalFormat; import java.util.*; import java.math.*; public class Main { /** * @param args */ static double min(double a,double b) { if(a>b) return b; return a; } static double max(double a,double b) { if(a>b) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2545
http://poj.org/problem?id=2545 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { TreeSet< Long> t=new TreeSet< Long>(); Scanner in=new Scanner(System.in); long a=in.nextInt(); long b=in.nextInt(); long c=in.nextInt(); int d=in.nextInt(); long[] arr=new long[d+1]; arr[0]=1; int x1=0,x2=0,x3=0; for(int i=1;i<=d;i++) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2539
http://poj.org/problem?id=2539 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; import java.math.*; public class Main { static BigInteger digit100=new BigInteger("1"); static int t,a,b; static void start(){ for(int i=0;i< 100;++i) digit100 = digit100.multiply(BigInteger.valueOf(10)); } public static void main(String[]args) throws Exception{ BigInteger num1,num2,temp,ans; start(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2538
http://poj.org/problem?id=2538 //* @author mekarlos@gmail.com import java.util.Hashtable; import java.util.Scanner; public class Main { public static void main(String[] args) { String[] s={"`1234567890-=","QWERTYUIOP[]","ASDFGHJKL;’","ZXCVBNM,./"}; Scanner scan=new Scanner(System.in); s[1]+=(char)(92); String cad="",out=""; Hashtable< String,String> table=new Hashtable< String,String>(); for(int i=0;i< 4;i++){ for(int j=1;j< s[i].length();j++){ table.put(s[i].charAt(j)+"", s[i].charAt(j-1)+""); } … Continue reading
Posted in poj
Leave a comment
Poj Solution 2537
http://poj.org/problem?id=2537 //* @author: import java.util.*; public class Main { static public void main( String [] str ){ Scanner sc = new Scanner(System.in); while( sc.hasNext()) { double s=1,answer; int k=sc.nextInt(); int n=sc.nextInt(); double ans[][]=new double[n][k+1]; for( int i=0; i< n; i++ … Continue reading
Posted in poj
Leave a comment
Poj Solution 2535
http://poj.org/problem?id=2535 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ public static void main(String args[]) { Scanner sc=new Scanner(System.in); int cnt[]=new int[101]; int temp[]=new int[101]; boolean arr[]=new boolean[101]; int n,p,i,j; n=sc.nextInt(); p=sc.nextInt(); Arrays.fill(cnt,0); Arrays.fill(arr,false); for(i=0;i< n;i++) { int max=0,min=999999; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2533
http://poj.org/problem?id=2533 import java.io.BufferedInputStream; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); if (scan.hasNext()) { int n = scan.nextInt(); int[] data = new int[n]; int[] count = new int[n]; for (int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2531
http://poj.org/problem?id=2531 /* @author: */ import java.util.Scanner; public class Main{ int c[][]=new int[22][22]; int result=0; int n; boolean sign[]=new boolean[22]; int v[]=new int[22]; int find(int k,int a,int r){ int temp=0; if(a+r<=result) return result; if(k==n+1){ if(a>result) result=a; return result; } sign[k]=false; for(int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2528
http://poj.org/problem?id=2528 //* @author: <strong>Yeming Hu</strong>"cslittleye@gmail.com" import java.util.*; import java.io.*; public class Main { public static int N = 10000; public static Node head; public static void main(String[] args) { Scanner sc = new Scanner(new BufferedInputStream(System.in)); Set< Integer> endpoints = new TreeSet< … Continue reading
Posted in poj
Leave a comment
Poj Solution 2526
http://poj.org/problem?id=2526 #include "stdio.h" #include "algorithm" using namespace std; struct point { int x,y; }p[10000]; inline bool cmp( point a, point b ) { return a.x < b.x || ( a.x == b.x && a.y < b.y ); } int n; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2524
http://poj.org/problem?id=2524 import java.io.BufferedInputStream; import java.util.Scanner; public class Main { public static void main(String[] args) { final int MAXSIZE = 50001; Scanner scan = new Scanner(new BufferedInputStream(System.in)); int caseI = 1; int max = 0; while (scan.hasNext()) { int n = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2522
http://poj.org/problem?id=2522 #include "iostream" using namespace std; int ans[230][11]; int get( int a, int b ) { int i; if( b == 1 ) return 1; if( ans[a][b] < 0 ) { ans[a][b] = 0; for( i=0; i*b<=a; i++ ) ans[a][b] … Continue reading
Posted in poj
Leave a comment
Poj Solution 2521
http://poj.org/problem?id=2521 import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(cin.hasNext()) { String tmp = cin.nextLine(); if(tmp.equals("0 0 0 0")) break; String[] tmp1 = tmp.split(" "); int N = Integer.valueOf(tmp1[0]); int M … Continue reading
Posted in poj
Leave a comment
Poj Solution 2516
http://poj.org/problem?id=2516 #include <stdio.h> #include <vector> #include <algorithm> using namespace std; typedef int type; const type MAX_FEE = 1e8; const int size = 210; const int MAX = 1e8; struct edge { int c,f; type w; int from,to; int rev_i; }; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2515
http://poj.org/problem?id=2515 import java.io.*; import java.util.*; import java.math.*; /** * * @author gongshaoqing */ public class Main { private static int NULL=0; public static void main(String[] args) { Scanner cin = new Scanner(System.in); int i, j, t; int m; BigInteger N, … Continue reading
Posted in poj
Leave a comment
Poj Solution 2513
http://poj.org/problem?id=2513 //* @author: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { int sum = 0; int time[] = new int[500000]; int parent[] = new int[500000]; int rank[] = new int[500000]; trieT root; void ini() { root = new … Continue reading
Posted in poj
Leave a comment
Poj Solution 2512
http://poj.org/problem?id=2512 #include <stdio.h> int dx[]={ 0, 0, 1,-1, 1, 1,-1,-1, 1, 1, 2, 2,-1,-1,-2,-2 }; int dy[]={-1, 1, 0, 0, 1,-1, 1,-1, -2, 2,-1, 1,-2, 2,-1, 1 }; char map[8][9]; #define true ‘.’ #define false ‘x’ inline bool inmap( int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2511
http://poj.org/problem?id=2511 #include <stdio.h> #include <memory.h> #include <string.h> #include <algorithm> using namespace std; char word[2500][100]; char mem[2500][100]; int v[2500]; int e[2500][2500]; int d[2500]; int id[2500]; int ans[2500][10]; int from[2500][10]; int n; bool cmp( int a, int b ) { return strcmp( … Continue reading
Posted in poj
Leave a comment
Poj Solution 2509
http://poj.org/problem?id=2509 //* @author ������<hongxp11@163.com> import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()) { int n = in.nextInt(); int k = in.nextInt(); int temp = n; int add = 0; while(n>=k) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2508
http://poj.org/problem?id=2508 //* @author: import java.util.*; public class Main { static public void main( String [] str ){ Scanner sc = new Scanner(System.in); double r, h, d1, a1, d2, a2, dg, l, s, a; while(sc.hasNext()) { r=sc.nextDouble(); h=sc.nextDouble(); d1=sc.nextDouble(); a1=sc.nextDouble(); d2=sc.nextDouble(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2507
http://poj.org/problem?id=2507 //* @author: 82638882@163.com import java.io.*; import java.util.Arrays; public class Main { public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); while(in.ready()) { String[] ss=in.readLine().split(" "); double x=Double.parseDouble(ss[0]); double y=Double.parseDouble(ss[1]); double c=Double.parseDouble(ss[2]); double max=Math.min(x, y),min=0; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2506
http://poj.org/problem?id=2506 import java.util.*; import java.math.*; public class Main{ static BigInteger[] ans; public static void main(String args[]) { Scanner sc=new Scanner(System.in); ans=new BigInteger[251]; ans[0]=BigInteger.valueOf(1); ans[1]=BigInteger.valueOf(1); ans[2]=BigInteger.valueOf(3); for(int i=3;i<=250;i++) ans[i]=ans[i-1].add(ans[i-2].multiply(BigInteger.valueOf(2))); while(sc.hasNextInt()){ int n=sc.nextInt(); System.out.println(ans[n]); } } }
Posted in poj
Leave a comment
Poj Solution 2505
http://poj.org/problem?id=2505 //* @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()) { double m=in.nextDouble(); while(m>18) m/=18; System.out.println(m>9?"Ollie wins.":"Stan wins."); } } }
Posted in poj
Leave a comment
Poj Solution 2504
http://poj.org/problem?id=2504 /* @author: */ import java.util.Scanner; public class Main{ public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n; double xx1,xx2,xx3,yy1,yy2,yy3,x,y,mnx,mxx,mny,mxy; int t=1; while(sc.hasNext()) { n=sc.nextInt(); if(n==0) break; xx1=sc.nextDouble(); yy1=sc.nextDouble(); xx2=sc.nextDouble(); yy2=sc.nextDouble(); xx3=sc.nextDouble(); yy3=sc.nextDouble(); double A1=2*(xx1-xx2); double A2=2*(xx1-xx3); double … Continue reading
Posted in poj
Leave a comment
Poj Solution 2502
http://poj.org/problem?id=2502 //* @author: import java.util.Scanner; import java.io.*; public class Main{ double max = Double.MAX_VALUE; int fin[] = new int[205]; double d[] = new double[205]; double dis[][] = new double[205][205]; pos p[] = new pos[205]; void initial() { for (int i … Continue reading
Posted in poj
Leave a comment
Poj Solution 2501
http://poj.org/problem?id=2501 //* @author import java.io.*; import java.util.*; import java.text.DecimalFormat; public class Main { static int hh; static int mm; static int ss; static double sumDist; static double speed; public static void main(String[] args) throws Exception { readFile(); } static void … Continue reading
Posted in poj
Leave a comment
Poj Solution 2500
http://poj.org/problem?id=2500 #include <iostream> #include <math.h> #include <algorithm> using namespace std; int n,c,g; double d,r; const double pi = 3.1415926535898; const double eps = 1e-8; double area(int a, int b, int c ) { double l1, l2; l1 = sin( pi*abs(a-b)/n … Continue reading
Posted in poj
Leave a comment
Poj Solution 2499
http://poj.org/problem?id=2499 //* @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 cnt=0; while((a–)!=0) { int b=in.nextInt(); int c=in.nextInt(); cnt++; int d=0,e=0; while(true) { if(b>c) { d+=b/c; b=b%c; if(b==0) break; … Continue reading
Posted in poj
Leave a comment