Monthly Archives: December 2011

Poj Solution 2011

http://poj.org/problem?id=2011 #include <stdio.h> #include <math.h> #include <algorithm> using namespace std; int ans[20], an; int temp[20]; int get( int num, int s, int &r ) { int g = 0, tg=1, tr=1; bool key = true; r = 0; while( num … Continue reading

Posted in poj | Comments Off on Poj Solution 2011

Poj Solution 2010

http://poj.org/problem?id=2010 #include<stdio.h> #include<vector> #include<queue> #include<algorithm> using namespace std; priority_queue< int ,vector<int> > q; typedef pair< int, int > cow; cow c[1000000]; int money[100000]; int n, m, f; int main() { int i, v; scanf( "%d %d %d", &n, &m, &f … Continue reading

Posted in poj | Comments Off on Poj Solution 2010

Poj Solution 2008

http://poj.org/problem?id=2008 #include <stdio.h> #include <algorithm> #include <queue> using namespace std; pair<int,int> p[1000]; pair<int,int> q[1000]; bool cmp( const pair<int,int> &a, const pair<int,int> &b ) { return a.second < b.second; } int main( ) { int a, b, c, n, i, j, … Continue reading

Posted in poj | Comments Off on Poj Solution 2008

Poj Solution 2007

http://poj.org/problem?id=2007 #include<stdio.h> #include<stdlib.h> #include<math.h> #define debug 0 #define INF 1000 #if debug #define NMAX 10 #else #define NMAX 52 #endif int point[NMAX][2]; int base[2]; int m[5]; int qu(int p[]) { if(p[0]>0&&p[1]>0) return 1; if(p[0]<0&&p[1]>0) return 2; if(p[0]<0&&p[1]<0) return 3; if(p[0]>0&&p[1]<0) … Continue reading

Posted in poj | Comments Off on Poj Solution 2007

Poj Solution 2005

http://poj.org/problem?id=2005 //* @author: <strong> import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int tot[]=new int[12],t[]=new int[4]; char ts[]=new char[5]; int sum,s1,s2,win,tem; while (sc.hasNext()) { int n=sc.nextInt(); if(n==0) break; for (int i=2;i< 10;i++) … Continue reading

Posted in poj | Comments Off on Poj Solution 2005

Poj Solution 2004

http://poj.org/problem?id=2004 //* @author: 82638882@163.com import java.io.*; import java.util.Arrays; import java.util.Comparator; public class Main { static my[] s=new my[10001]; public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int l=0,max=-1,rr=-1; while(in.ready()) { String t=in.readLine(); s[l++]=new my(t); … Continue reading

Posted in poj | Comments Off on Poj Solution 2004

Poj Solution 2002

http://poj.org/problem?id=2002 #include <stdio.h> #include <math.h> #include <string.h> #include <algorithm> using namespace std; #define DIFF 20000 #define MAX 1005 #define NUM 40005 #define EP 1e-8 #define LIM 1e-6 #define PI acos(-1.0) struct pt{ int x,y; }; pt p[MAX]; int s[NUM],e[NUM]; int … Continue reading

Posted in poj | Comments Off on Poj Solution 2002

Poj Solution 2001

http://poj.org/problem?id=2001 import java.util.*; public class Main { static int MAX = 1010; static TrieNode root = new TrieNode(); static char[][] result = new char[MAX][22]; static char[][] s = new char[MAX][22]; public static void main(String[] args) { Scanner cin = new … Continue reading

Posted in poj | Comments Off on Poj Solution 2001

Poj Solution 2000

http://poj.org/problem?id=2000 import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(true) { int day = Integer.valueOf(cin.nextLine()).intValue(); if(day == 0) break; System.out.println(day + " " + getTotalCoin(day)); } } private static int getTotalCoin(int … Continue reading

Posted in poj | Comments Off on Poj Solution 2000

Poj Solution 1995

http://poj.org/problem?id=1995 //* @author: import java.util.*; public class Main{ //��a^b%n private static int modexp(int a,int b,int n) { int ret=1; int tmp=a; while(b!=0) { if((b&0x1)==1) ret=ret*tmp%n; tmp=tmp*tmp%n; b>>=1; } return ret; } public static void main(String[] args){ Scanner sc=new Scanner(System.in); int … Continue reading

Posted in poj | Comments Off on Poj Solution 1995

Poj Solution 1990

http://poj.org/problem?id=1990 //* @author: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; /* *�ο���ţ�ij���,��һ��д��״����… *�Ƚ�cows��volumeΪ�ؼ�������.. *}����״����,һ��ά�������,һ��ά��ǰ����С�ڵ�ǰ������֮�� */ class cin { static BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static int leave=0; static int nextInt() throws IOException { … Continue reading

Posted in poj | Comments Off on Poj Solution 1990

Poj Solution 1989

http://poj.org/problem?id=1989 //* @author: ccQ.SuperSupper import java.util.*; import java.math.*; public class Main { public static void main(String []args) throws Exception{ int i,j,k,n,ans; int way[] = new int[100100]; int flag[] = new int[10100]; Scanner cin = new Scanner(System.in); n = cin.nextInt(); k … Continue reading

Posted in poj | Comments Off on Poj Solution 1989

Poj Solution 1988

http://poj.org/problem?id=1988 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ static int p[]=new int[30010]; static int d[]=new int[30010]; static int num[]=new int[30010]; static int i=0; static char c[]=new char[5]; static int getup(int a) { int b=a; while(p[b]!=b) b=p[b]; return … Continue reading

Posted in poj | Comments Off on Poj Solution 1988

Poj Solution 1987

http://poj.org/problem?id=1987 #include"stdio.h" #include"algorithm" using namespace std; long use[16]; long father[40010]; long queue[40010]; long lchild[40010][16]; long rchild[40010][16]; long sum[40010][16]; long depth[40010][16]; long value[40010],dist[40010]; long m,n,k,kind,answer; long findit(long key,long s1,long deep) { long &lc=lchild[s1][deep],&rc=rchild[s1][deep],sumnow=sum[s1][deep]; long now=depth[s1][deep]; if(now==key) { if(rc>=0)return sumnow-sum[rc][deep+1]; else return … Continue reading

Posted in poj | Comments Off on Poj Solution 1987

Poj Solution 1981

http://poj.org/problem?id=1981 #include<iostream> #include"math.h" #include"algorithm" using namespace std; struct point { double x,y; }p[310]; double jl(point i,point j) { return sqrt((i.x-j.x)*(i.x-j.x)+(i.y-j.y)*(i.y-j.y)); } bool fzk(point a,point b,double &in,double &out) { double jiao,l,x; if((l=jl(a,b))>2)return 0; jiao=atan2(b.y-a.y,b.x-a.x); x=acos(l/2); in=jiao-x; out=jiao+x; return 1; } int … Continue reading

Posted in poj | Comments Off on Poj Solution 1981