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 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
Poj Solution 2498
http://poj.org/problem?id=2498 //* @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 count=1; int[] arr=new int[]{9,3,7}; while((a–)!=0) { String s=in.next(); int total=0; int k=0; int p=0; int t=s.length(); for(int i=t-1;i>-1;i–) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2497
http://poj.org/problem?id=2497 //* @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); int a=Integer.parseInt(in.readLine()); int cnt=0; while((a–)!=0) { cnt++; String[] ss=in.readLine().split(" "); int t=Integer.parseInt(ss[0]); int w=Integer.parseInt(ss[1]); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2496
http://poj.org/problem?id=2496 #include <stdio.h> #include <algorithm> using namespace std; int e[100][100]; int n; int p; int a[10000]; int main() { int cas, i, j, l, k, ans; scanf( "%d", &cas ); for( l=1; l<=cas; l++ ) { scanf( "%d", &p ); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2495
http://poj.org/problem?id=2495 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { /** * @param args */ public static void main(String[] args)throws Exception { // TODO Auto-generated method stub int a,b,c,d,t,i; Scanner cin = new Scanner(System.in); t = cin.nextInt(); for(i=1;i<=t;++i){ … Continue reading
Posted in poj
Leave a comment
Poj Solution 2492
http://poj.org/problem?id=2492 //* @author: 82638882@163.com import java.io.*; public class Main { static my[] p; public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int a=Integer.parseInt(in.readLine()); int cnt=0; while((a–)!=0) { cnt++; String[] ss=in.readLine().split(" "); int n=Integer.parseInt(ss[0]); p=new … Continue reading
Posted in poj
Leave a comment
Poj Solution 2491
http://poj.org/problem?id=2491 #include <stdio.h> #include <string.h> int next[400]; bool ishead[400]; char w1[400][100],w2[400][100]; int main() { int cas, i, n, j, k = 0; scanf( "%d", &cas ); while( cas– ) { scanf( "%d", &n ); n–; for( i=0; i<n; i++ ) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2489
http://poj.org/problem?id=2489 #include <stdio.h> #include <math.h> #include <memory.h> #include <algorithm> using namespace std; struct point { int x,y; }; struct line { point a,b; int dx,dy; }l[100001]; int n; __int64 ans; inline double crossproduct(point o, point a, point b) { return … Continue reading
Posted in poj
Leave a comment
Poj Solution 2488
http://poj.org/problem?id=2488 import java.io.PrintWriter; import java.util.Scanner; import java.util.Stack; public class Main { static class Point{ int x ,y; public Point(int x ,int y){ this.x = x; this.y = y; } } static int[][] chessboard = new int[27][27]; static int num = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2487
http://poj.org/problem?id=2487 import java.io.BufferedInputStream; import java.util.Scanner; /** * *poj2487 * @author NC */ public class Main { private static int partition(int[] array, int low, int high) { int key = array[low]; while (low < high) { while (low < high && … Continue reading
Posted in poj
Leave a comment
Poj Solution 2486
http://poj.org/problem?id=2486 #include <iostream> #include <list> #include <algorithm> using namespace std; int value[100]; int gone[100][201],m,K,n; int back[100][201]; list<int> e[100]; void merge_back(int bk1[], int bk2[], int bk[], int maxstep ) { int i,j; for( i=0; i<=maxstep; i++ ) { bk[i] = bk2[i]; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2485
http://poj.org/problem?id=2485 import java.util.Scanner; public class Main{ public static void main(String argvs[]){ int matrix[][]; int Max=65536; int m,n,t,i,j,k,max_len,count,num,min,point=0; int temp1[],temp2[],flag[]; Scanner in=new Scanner(System.in); t=in.nextInt(); for(i=0;i< t;i++){ n=in.nextInt(); matrix=new int[n][n]; flag=new int[n]; for(j=0;j< n;j++) flag[j]=0; flag[0]=1; count=0; num=0; min=Max; max_len=0; temp1=new int[n*(n-1)/2]; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2479
http://poj.org/problem?id=2479 import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { int t; int l; int[] a; String[] s; int[] left; int[] right; int max = 0; int temp; public Main() throws Exception { BufferedReader read = new BufferedReader(new InputStreamReader( System.in)); t … Continue reading
Posted in poj
Leave a comment
Poj Solution 2477
http://poj.org/problem?id=2477 #include<iostream> #include"stdio.h" using namespace std; struct tree { int l,r; __int64 value; int child; }t[100]; int n,root; bool init() { int i,times[100]; cin>>n; if(n==0) return 0; for(i=1;i<=n;i++) times[i]=0; for(i=1;i<=n;i++) { cin>>t[i].l>>t[i].r; if(t[i].l>0) times[t[i].l]++; if(t[i].r>0) times[t[i].r]++; } for(i=1;i<=n;i++) if(times[i]==0) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2473
http://poj.org/problem?id=2473 #include<iostream> #include"algorithm" using namespace std; struct rect { int x1,x2,y1,y2; }r[210]; int n,w,h,n1,n2,m; int x[411],y[411]; void init() { int i; cin>>n>>w>>h; for(i=0;i<n;i++) { cin>>r[i].x1>>r[i].y1>>r[i].x2>>r[i].y2; x[i]=r[i].x2; y[i]=r[i].y2; } m=n+1; x[n]=0,y[n]=0; std::sort(x,x+m); std::sort(y,y+m); n1=std::unique_copy(x,x+m,x)-x; n2=std::unique_copy(y,y+m,y)-y; } inline int max(int a,int b) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2472
http://poj.org/problem?id=2472 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { static int N = 100+5; static int n; static double Graph[][] = new double[N][N]; public static void init(){ int i,j; for(i=0;i< N;++i) for(j=0;j< N;++j) Graph[i][j] = 0.0; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 2470
http://poj.org/problem?id=2470 //* @author ������<hongxp11@163.com> //�t���� buffered import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); while (true) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2469
http://poj.org/problem?id=2469 #include<iostream> using namespace std; char *suit[]={"Clubs", "Diamonds", "Hearts", "Spades"}; char *value[]={"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"}; int shuffles[101][52],n; int card[52]; void init() { int i,j; cin>>n; for(i=0;i<n;i++) for(j=0;j<52;j++) cin>>shuffles[i][j]; for(i=0;i<52;i++) card[i]=i; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 2465
http://poj.org/problem?id=2465 #include<iostream> using namespace std; inline int min(int a,int b) { return a<b?a:b; } int dis[112],price[112]; int l,n; void init() { n=0; cin>>l; while(cin>>dis[n]) cin>>price[n++]; price[n]=99999999; dis[n]=l; n++; } int doit() { int i,j,s,temp[212],p; int best[212]; for(i=0;i<201;i++) best[i]=-1; best[100]=0; for(s=dis[0],i=0;i<n;i++) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2463
http://poj.org/problem?id=2463 #include<iostream> #include"math.h" using namespace std; double k,l,s,w; const double g=9.81; bool init() { cin>>k>>l>>s>>w; return !(k==0&&l==0&&s==0&&w==0); } int calculate() { double v,v0,h,vv; if(s<=l||k==0) { v=sqrt(2*s*g); if(v>10)return -1; else return 1; } else { v0=sqrt(2*l*g); h=(2*w*g+sqrt(4*w*w*g*g+8*k*w*g*l))/(2*k); h+=l; if(h<s)return 0; vv=(2*w*g*s-k*(s-l)*(s-l))/w; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2460
http://poj.org/problem?id=2460 //* @author: ccQ.SuperSupper import java.io.*; class point{ int x,y; } public class Main { static int n; static final int N = 200000+100; static point position[] = new point[N]; public static void main(String[]args) throws Exception{ int i; start(); StreamTokenizer … Continue reading
Posted in poj
Leave a comment
Poj Solution 2459
http://poj.org/problem?id=2459 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { static final int N = 2000+10; static int DP[] = new int[N]; public static void main(String[]args) throws Exception{ int n,F1,F2,Day,i,sum,a,b,j; //Scanner cin = new Scanner(new FileInputStream("input.txt")); Scanner cin … Continue reading
Posted in poj
Leave a comment
Poj Solution 2458
http://poj.org/problem?id=2458 #include "stdio.h" char map[6][6]; bool sign[6][6]; int flag[6][6]; bool inline inmap( int x, int y ) { return 0<=x&&x<5&&0<=y&&y<5; } int dx[]={ 0,-1, 0, 1}; int dy[]={-1, 0, 1, 0}; int ans; int reach; int visit; void find( int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2457
http://poj.org/problem?id=2457 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { static final int N = 10000+10; static int meat[] = new int[N],pre[] = new int[N],n,K; static Vector Graph[] = new Vector[N]; static Queue que = new LinkedList<Integer>(); static … Continue reading
Posted in poj
Leave a comment
Poj Solution 2456
http://poj.org/problem?id=2456 #include <stdio.h> #include <algorithm> using namespace std; int pos[100000], n, cc; bool check( int l ) { int i, r, j; for( r=cc-1,i=0,j=1; j<n && r; j++ ) { if( pos[j]-pos[i]>=l ) { r–; i=j; } } return r … Continue reading
Posted in poj
Leave a comment
Poj Solution 2454
http://poj.org/problem?id=2454 #include"stdio.h" #include"memory.h" #include"algorithm" #include"stdlib.h" using namespace std; typedef pair<int,int> city; city c[180]; int n, k; void init() { int i; scanf( "%d", &n ); k = n; n *= 3; for( i=0; i<n; i++ ) { scanf( "%d", &c[i].first … Continue reading
Posted in poj
Leave a comment
Poj Solution 2453
http://poj.org/problem?id=2453 import java.util.Scanner; public class Main { /** * 获得一个Integer对应的二进制中1的个数 * @param i * @return sum */ public static int getSum(int i) { int sum = 0; while (i > 0) { i = i & (i – 1); ++sum; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2452
http://poj.org/problem?id=2452 //* @author: import java.util.*; public class Main { static public void main( String [] str ) throws Exception{ Scanner sc = new Scanner(System.in); int i, j, h, ans; while(sc.hasNext()) { int n=sc.nextInt(); int s[]=new int[n]; for( i=0; i< n; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2450
http://poj.org/problem?id=2450 //* @author: import java.util.*; import java.math.*; public class Main { static int gcd(int a,int b) { int c; while( (a%=b) != 0 ) { c=b; b=a; a=c; } return b; } static int a,b,c,d,n,m,p,q; static int t[] = new … Continue reading
Posted in poj
Leave a comment
Poj Solution 2447
http://poj.org/problem?id=2447 #include<stdlib.h> #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; typedef unsigned __int64 u64; #define MAX 30 #define MAXN 5 u64 len, dig, limit; u64 factor[MAXN]; u64 mod(u64 a, u64 b, u64 n){ if(!a)return 0; else return ( ((a&dig)*b)%n + (mod(a>>len,b,n)<<len)%n )%n; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2446
http://poj.org/problem?id=2446 #include<iostream> #include<string> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; const int MAXN=1050; int link[MAXN]; int total; bool vist[33][33]; //用来标记那些位置有洞 bool usedif[MAXN]; bool mat[MAXN][MAXN]; bool Can(int t) { int i; for(i=0;i<total;i++) if(mat[t][i]&&!usedif[i]) { usedif[i]=true; if(link[i]==-1||Can(link[i])) { link[i]=t; return true; … Continue reading
Posted in poj
Leave a comment