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 2859
http://poj.org/problem?id=2859 #include <vector> #include <algorithm> #include <stdio.h> using namespace std; typedef pair<int,int> point; int n, a, b; point p[500100]; void input( ) { int i; scanf( "%d", &n ); scanf( "%d%d", &a, &b ); for( i=0; i<n; i++ ) scanf( … Continue reading
Posted in poj
Leave a comment
Poj Solution 2858
http://poj.org/problem?id=2858 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; char w[100100][11]; char *p[11][100100]; int pn[11]; bool cmpw( char *a, char *b ) { return strcmp( a, b ) < 0; } struct tile{ char c[2]; int v; }tiles[10]; bool … Continue reading
Posted in poj
Leave a comment
Poj Solution 2857
http://poj.org/problem?id=2857 import java.util.*; /** * * @author leo */ public class Main { public static int judge(double H,double V,double h,double v,double x,double y,int state){ if((x>H*h&&y< V*v)||(x< H*h&&y>V*v)){ return state; }else{ state++; if(x< h*H&&y< v*V){ return judge(H*h,v*V,h,v,x,y,state); }else{ return judge(H*(1.0-h),V*(1.0-v),h,v,x-H*h,y-V*v,state); } … Continue reading
Posted in poj
Leave a comment
Poj Solution 2853
http://poj.org/problem?id=2853 //* @author: 82638882@163.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int u=in.nextInt(); while((u–)!=0) { int y=in.nextInt(); int a=in.nextInt(); int count=0; int t=1; for(int i=2;i< (Math.sqrt(2*a)+1);i++) { t+=i; if((a-t)%i==0&&a>=t) count++; } System.out.println(y+" … Continue reading
Posted in poj
Leave a comment
Poj Solution 2849
http://poj.org/problem?id=2849 //2849 #include <iostream> #include <cstdio> #include <vector> #include <string> #include <cstring> using namespace std; int Array[32768]; string Program; string input; int index; int inputP; int PromP; int cc; int Programsize; inline void IncP() { index = (index + 1) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2847
http://poj.org/problem?id=2847 //* @author:alpc12 import java.io.*; import java.util.*; import java.math.*; public class Main { String num; boolean ok; void DFS(int dep, String b) { if(b.length() == num.length()) return; int i, j; for(i = 0; i <= 9; ++i) { BigInteger now … Continue reading
Posted in poj
Leave a comment
Poj Solution 2845
http://poj.org/problem?id=2845 import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int pnum = Integer.valueOf(cin.nextLine()).intValue(); for(int i = 1; i <= pnum; i++) { String[] str = cin.nextLine().split(" "); String a = removePreZero(str[0]); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2842
http://poj.org/problem?id=2842 #include <stdio.h> int an[10], bn[10]; int sa[10], sb[10]; int p[10], n, m, g, h; int S[500000], T[500000]; int get_T( int *a ) { int index = 0, i; for( i=0; i<n; i++ ) index += a[i]*sa[i]; return T[ index … Continue reading
Posted in poj
Leave a comment
Poj Solution 2840
http://poj.org/problem?id=2840 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(); for(int i = 0; i < num; i++) { String[] str = cin.nextLine().split(":"); int hour = Integer.valueOf(str[0]).intValue(); int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2838
http://poj.org/problem?id=2838 #include <stdio.h> struct edge { edge *pri; edge *next; }; edge *e[1010]; edge temp[1010][1010]; void add( int from, int to ) { temp[from][to].next = e[from]; temp[from][to].pri = 0; if( e[from] ) e[from]->pri = temp[from]+to; e[from] = temp[from]+to; } void … Continue reading
Posted in poj
Leave a comment
Poj Solution 2837
http://poj.org/problem?id=2837 #include <stdio.h> int ans[512][512]; int main( ) { int i, j, k, n; ans[0][0] = 1; scanf( "%d", &n ); for( i=1; i<(1<<n); i<<=1 ) { for( j=i; j<i*2; j++ ) for( k=i; k<i*2; k++ ) ans[j][k] = ans[j-i][k-i]; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2834
http://poj.org/problem?id=2834 #include <stdio.h> #include <memory.h> #include <algorithm> #include <vector> using namespace std; vector<int> e[10010], dest; int n, m; vector< pair<int,int> > jon, cely; void input( ) { int a, b; scanf( "%d", &n ); scanf( "%d", &m ); while( m– … Continue reading
Posted in poj
Leave a comment
Poj Solution 2833
http://poj.org/problem?id=2833 //* @author: 82638882@163.com import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); StringBuffer buf=new StringBuffer(); try { while(true) { char c; int[] u=new int[3]; for(int i=0;i< 3;i++) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2823
http://poj.org/problem?id=2823 #include <stdio.h> #include <algorithm> using namespace std; int a[1000100], l[1000100], ans[1000100]; int pt[1000100], st[1000100], n, k, m; bool cmp( int x, int y ) { return a[x] < a[y]; } void calc( ) { int i, j, h, sn; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2818
http://poj.org/problem?id=2818 /* @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 sum,a[]=new int[4],b[]=new int[4],sum1=0; while(true) { a[0]=sc.nextInt(); a[1]=sc.nextInt(); a[2]=sc.nextInt(); a[3]=sc.nextInt(); sum=sc.nextInt(); if(a[0]==0 && a[1]==0 && a[2]==0 &a[3]==0 … Continue reading
Posted in poj
Leave a comment
Poj Solution 2817
http://poj.org/problem?id=2817 #include <stdio.h> #include <memory.h> #include <string.h> int ans[12][1024][10]; int link[10][10]; int len[10]; char w[10][20]; int join_num( int i, int j ) { int k, l, ans = 0, h; for( k=0; w[i][k]; k++ ) { for( l=0, h=0; w[i][k+l] … Continue reading
Posted in poj
Leave a comment
Poj Solution 2816
http://poj.org/problem?id=2816 #include <stdio.h> #include <memory.h> #include <string.h> #include <math.h> char map[200][200]; bool ok[200][200]; int gx, gy, n, m, t, r; const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 }; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2815
http://poj.org/problem?id=2815 #include <stdio.h> #include <memory.h> #include <string.h> #include <math.h> double get_angle( double s, double f, double m ) { if( s >= 12 ) s -= 12; s = ( s+f/60+m/7200 ) / 12 * 360; f = ( f+m/120 … Continue reading
Posted in poj
Leave a comment
Poj Solution 2812
http://poj.org/problem?id=2812 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; class POINT{ double x,y; } public class Main { static final int N = 100000; static POINT point[] = new POINT[N]; static int n; static void start(){ for(int i=0;i< N;++i) point[i] = … Continue reading
Posted in poj
Leave a comment
Poj Solution 2810
http://poj.org/problem?id=2810 #include <stdio.h> #include <memory.h> #include <vector> #include <string> using namespace std; vector<string> v; int main( ) { double a, b; int i, j; char w[1000], unit[1000]; while( 1 ) { scanf( "%lf %s %lf %1s", &a, unit, &b, w … Continue reading
Posted in poj
Leave a comment
Poj Solution 2800
http://poj.org/problem?id=2800 //* @author: <strong>Yeming Hu</strong>"cslittleye@gmail.com" import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n,k; while(sc.hasNext()) { n = sc.nextLong(); k = sc.nextLong(); long sum; if(n<=k) { sum = sumMod(k,n); }else { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2799
http://poj.org/problem?id=2799 //* @author: SmilingWang import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); IPAddress[] ips = new IPAddress[n]; for(int i = 0; i < … Continue reading
Posted in poj
Leave a comment
Poj Solution 2796
http://poj.org/problem?id=2796 //* @author: 82638882@163.com import java.io.*; public class Main { static int[] b,c; static long[] e,d,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()); p=new long[a+2]; b=new int[a+1]; c=new int[a+1]; d=new long[a+1]; e=new … Continue reading
Posted in poj
Leave a comment
Poj Solution 2785
http://poj.org/problem?id=2785 //* @author: 82638882@163.com import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); String s=in.readLine(); int a=Integer.parseInt(s); int[] t1=new int[a]; int[] t2=new int[a]; int[] t3=new int[a]; int[] … Continue reading
Posted in poj
Leave a comment
Poj Solution 2782
http://poj.org/problem?id=2782 //* @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 b=in.nextInt(); ArrayList< Integer> t=new ArrayList< Integer>(); while((a–)!=0) t.add(in.nextInt()); Collections.sort(t); int count=0; int u=t.size()-1; int k=0; while(k<=u) { int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2781
http://poj.org/problem?id=2781 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<string.h> #include<math.h> #define INF 3000000 #define NMAX 1000000 int N; typedef struct { int len; int next[101]; }DATA; DATA a[NMAX]; int st,ed; void input() { int i,j; scanf("%d",&N); int tmp; for(i=0;i<N;i++) { scanf("%d%d",&tmp,&a[i].len); for(j=0;j<a[i].len;j++) { scanf("%d",&a[i].next[j]); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2780
http://poj.org/problem?id=2780 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; class Point implements Comparable { double x,y; public int compareTo(Object obj){ Point temp = (Point) obj; if(temp.x!=this.x){ if(temp.x< this.x) return 1; return -1; } if(temp.y< this.y) return 1; return -1; } } … Continue reading
Posted in poj
Leave a comment
Poj Solution 2777
http://poj.org/problem?id=2777 import java.io.*; import java.util.*; public class Main { static tree[] mytree=new tree[300003]; static boolean[] flag=new boolean[35]; public static void main(String args[]) throws Exception { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); String[] ss=in.readLine().split(" "); int l=Integer.parseInt(ss[0]); int t=Integer.parseInt(ss[1]); int o=Integer.parseInt(ss[2]); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2775
http://poj.org/problem?id=2775 #include "stdio.h" struct tree{ int l, r; int v; int ans; int nds; }t[200]; int n, m; int new_node( int value ) { t[m].l = t[m].r = -1; t[m].v = value; t[m].nds = 1; m++; return m-1; } int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2774
http://poj.org/problem?id=2774 #include "stdio.h" #include "memory.h" #include "string.h" #include "stdlib.h" const int CHAR_NUM = 27; const int MAXSIZE = 500000; struct suftree{ suftree *ch[CHAR_NUM]; char *l, *r; int len; suftree *s, *p; }suft[MAXSIZE]; int use_node = 0; /////////////////////////////////////////////// suftree *new_node( ) … Continue reading
Posted in poj
Leave a comment
Poj Solution 2773
http://poj.org/problem?id=2773 //* @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()) { int a=in.nextInt(); int b=in.nextInt(); if(a==1)System.out.println(b); else{ ArrayList< Integer> arr=new ArrayList< Integer>(); for(int i=1;i< a;i++) { int m=a,n=i; while(m%n!=0) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 2769
http://poj.org/problem?id=2769 //* @author mekarlos@gmail.com import java.util.Hashtable; import java.util.Scanner; public class Main { public static void main(String[] args) { Hashtable< Integer,Integer> table; Scanner scan=new Scanner(System.in); int M[]=new int[300]; int n=scan.nextInt(),k=0,m=1; boolean band=false; for(int i=0;i< n;i++){ k=scan.nextInt(); band=true; table=new Hashtable< Integer, Integer>(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2766
http://poj.org/problem?id=2766 /* @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 dx[]={0,1,0,-1},dy[]={1,0,-1,0}; int g[][]=new int[52][52]; int ca,i,j,k,n,r,x,y,dir; ca=sc.nextInt(); while ((ca–)!=0) { n=sc.nextInt(); r=sc.nextInt(); for(i=0;i< g.length;i++) Arrays.fill(g[i],0); for … Continue reading
Posted in poj
Leave a comment
Poj Solution 2765
http://poj.org/problem?id=2765 #include <stdio.h> #include <string.h> struct product{ char w[100]; char name[110][100]; int per[110]; int most[110], least[110]; int m; }p[10]; int n; void clac( product &a ) { int s = 0, r = 100, i, j, k, low[100], up[100], sum, … Continue reading
Posted in poj
Leave a comment
Poj Solution 2760
http://poj.org/problem?id=2760 #include "stdio.h" #include "math.h" #include "memory.h" #include "algorithm" using namespace std; #define y1 sdgdsf double clac( double h0, double h1, double x0, double x1 ) { return h0/(h0-h1)*( x1 – x0 ) + x0; } double sum[5048]; struct node … Continue reading
Posted in poj
Leave a comment
Poj Solution 2757
http://poj.org/problem?id=2757 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String args[]) throws Exception { Scanner cin=new Scanner(System.in); BigInteger n; long b; while(cin.hasNext()) { n=cin.nextBigInteger(); b=cin.nextLong(); if(n.compareTo(BigInteger.ZERO)<=0) { System.out.println("0"); continue; } BigInteger ans; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2756
http://poj.org/problem?id=2756 import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int num = Integer.valueOf(cin.nextLine()).intValue(); for(int i = 0; i < num; i++) { String[] str = cin.nextLine().split(" "); BigDecimal a … Continue reading
Posted in poj
Leave a comment
Poj Solution 2751
http://poj.org/problem?id=2751 /* @author: */ import java.util.Scanner; public class Main { static int a[][]=new int[10001][2]; static int b[][]=new int[10001][2]; static int an,bn; static void sort(){ int i,j,t1,t2; for(i=0;i< an;i++) for(j=0;j< an;j++) { if(a[i][0]< a[j][0]) { t1=a[i][0];t2=a[i][1]; a[i][0]=a[j][0];a[i][1]=a[j][1]; a[j][0]=t1;a[j][1]=t2; } } for(i=0;i< … Continue reading
Posted in poj
Leave a comment
Poj Solution 2750
http://poj.org/problem?id=2750 #include "stdio.h" #include "memory.h" const int SIZE = ( 1<<18 ); const int LEAF = ( 1<<17) – 1; int sum[SIZE],l_max[SIZE],r_max[SIZE],l_min[SIZE], r_min[SIZE], min_e[SIZE], s_max[SIZE], s_min[SIZE], pn, n; inline int max( int a, int b ) { return a>b?a:b; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 2749
http://poj.org/problem?id=2749 #include "stdio.h" #include "memory.h" #include "vector" #include "algorithm" #include "functional" #include "math.h" #define max asdfds using namespace std; const int SIZE = 700; typedef pair<int,int> pair_int; int sign[SIZE*2], MS; pair_int e[SIZE*2][SIZE*2], _e[SIZE*2][SIZE*2]; int en[SIZE*2], _en[SIZE*2]; int n; void init( … Continue reading
Posted in poj
Leave a comment
Poj Solution 2748
http://poj.org/problem?id=2748 import java.io.*; 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[] fb=new int[75000]; fb[0]=1; fb[1]=1; for(int i=2;i< 75000;i++) fb[i]=(3*fb[i-1]-fb[i-2]+200000)%100000; while((a–)!=0) { int b=Integer.parseInt(in.readLine()); System.out.println(fb[b%75000]); } } }
Posted in poj
Leave a comment
Poj Solution 2744
http://poj.org/problem?id=2744 /* @author: */ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double b,v,e,f,t[]=new double[101],t1; int n,a[]=new int[101],r; int i,j,k,dis; while(sc.hasNext()) { n=sc.nextInt(); if(n==0) break; a[0]=0; for(i=1;i<=n;i++) a[i]=sc.nextInt(); b=sc.nextDouble(); r=sc.nextInt(); v=sc.nextDouble(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2739
http://poj.org/problem?id=2739 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; System.out.println(test2(n)); } } /* * Sum of Consecutive Prime Numbers */ public static int test2(int x){ int count=0; for(int i=2;i+i< … Continue reading
Posted in poj
Leave a comment
Poj Solution 2738
http://poj.org/problem?id=2738 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { static final int M = 2,N = 1000+2; static int value[] = new int[N]; static int map[][][] = new int[N][N][M],n; public static int Get_Num(StreamTokenizer cin) throws Exception{ cin.nextToken(); … Continue reading
Posted in poj
Leave a comment
Poj Solution 2728
http://poj.org/problem?id=2728 //* @author: import java.util.*; import java.math.*; import java.io.FileReader; class Node{ int x,y,z; } public class Main { static int []mark=new int[1010]; static double []dis=new double[1010]; static int []from=new int [1010]; static double sumup,sumdown; static double [][]up=new double [1010][1010]; static … Continue reading
Posted in poj
Leave a comment
Poj Solution 2726
http://poj.org/problem?id=2726 //* @author: 82638882@163.com import java.io.*; import java.util.Arrays; class Main { public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); while(true) { int a=Integer.parseInt(in.readLine()); if(a==0) break; my[] p=new my[a]; for(int i=0;i< a;i++) { String[] ss=in.readLine().split(" … Continue reading
Posted in poj
Leave a comment
Poj Solution 2724
http://poj.org/problem?id=2724 #include <memory.h> #include <stdio.h> #include <string.h> #define null 0 const int size = 2010; bool e[size][size]; int maxmatch( int n, int m, bool w[][size], int *p) { int p_n[size]; int p_m[size]; bool sign[size]; int q[size],from[size],s,t; int i,j,link,now,h; memset( p_n, … Continue reading
Posted in poj
Leave a comment
Poj Solution 2722
http://poj.org/problem?id=2722 /* @author: */ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double angle,p,a,b,c,t,l,xa,xb,ya,yb,k1,k2,x1,x2,y1,y2,l2; int n,i; while(sc.hasNext()) { n=sc.nextInt(); if(n==0) break; xa=sc.nextDouble(); ya=sc.nextDouble(); xb=sc.nextDouble(); yb=sc.nextDouble(); l=l2=0; for(i=0;i< n;i++) { t=sc.nextDouble(); l+=t; … Continue reading
Posted in poj
Leave a comment
Poj Solution 2721
http://poj.org/problem?id=2721 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ private int a,b; private double f1,f2,f3,f4,f5,f6,t1,t2,t3,t4,t5,t6; public Main(int a,int b){ this.a=a; this.b=b; f1=13-a+1;f2=13-b+1;f3=1; t1=13;t2=13;t3=a+b; f4=1;f5=1;f6=26-(a+b)+1; t4=a;t5=b;t6=26; } public static void main(String args[]){ Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int a=sc.nextInt(); int … Continue reading
Posted in poj
Leave a comment
Poj Solution 2719
http://poj.org/problem?id=2719 import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(true) { String str = cin.nextLine(); char c = str.charAt(0); int re = 0; if(c == ‘0’) break; int size = str.length(); for(int … Continue reading
Posted in poj
Leave a comment