# Monthly Archives: May 2012

## Poj Solution 2182

http://poj.org/problem?id=2182 /* @author: */ import java.util.Scanner; public class Main{ public static void main(String args[]) { int p[]=new int[8010]; int q[]=new int[8080]; int n,k; Scanner sc=new Scanner(System.in); n=sc.nextInt(); p[0]=0; for(int i=1;i< n;i++) { k=sc.nextInt(); for(int j=i;j>k;j–) p[j]=p[j-1]; p[k]=i; } for(int i=0;i< … Continue reading

## Poj Solution 2181

http://poj.org/problem?id=2181 //* @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(); boolean flag=true; int sum=0; int[] arr=new int[a+1]; for(int i=0;i< a;i++) arr[i]=in.nextInt(); for(int i=0;i< a;i++) { if(flag) { if(arr[i]>arr[i+1]) { … Continue reading

## Poj Solution 2175

http://poj.org/problem?id=2175 #include <memory.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #define y1 yy1 const int size = 210; int dis[size][size], n, m; int x1[100], y1[100], x2[100], y2[100]; int s2[100], lim2[100]; int f[100][100]; inline int distance( int i, int j ) { … Continue reading

## Poj Solution 2173

http://poj.org/problem?id=2173 #include <stdio.h> #include <memory.h> #include <algorithm> using namespace std; typedef pair<int,int> point; int w, h, n; int a[110], x[110], y[110], m; point p[110]; void init( ) { int i, xx, yy; m = 0; n = 0; scanf( "%d … Continue reading

## Poj Solution 2172

http://poj.org/problem?id=2172 /* @author: */ import java.util.Scanner; public class Main { static final double EPS =1e-7; //����x*y �ܷ���� a*b �� static boolean canfit( double a, double b, double x, double y ) { double t; double l=Math.sqrt(x*x+y*y),ll=x*x+y*y; if(x*x+y*y – a*a-b*b > … Continue reading

## Poj Solution 2163

http://poj.org/problem?id=2163 //* @author: import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int m=sc.nextInt(); int n=sc.nextInt(); int k=sc.nextInt(); node a[]=new node[k+1]; for(int i=0;i<=k;i++) a[i]=new node(); for (int i=1;i<=k;i++) { a[i].p=sc.nextDouble(); a[i].pm=a[i-1].pm+a[i].p; a[i].pn=a[i-1].pn+a[i].p; if … Continue reading

## Poj Solution 2159

http://poj.org/problem?id=2159 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { public static void main(String[] args) throws Exception { BufferedReader read = new BufferedReader(new InputStreamReader( System.in)); String chips = null; String source; boolean flg; while ((chips … Continue reading

## Poj Solution 2155

http://poj.org/problem?id=2155 import java.util.Scanner; public class Main { private static int[][] matrix = new int[1001][1001]; private static int n; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int testNum = sc.nextInt(); for (int i = 0; i < … Continue reading

## Poj Solution 2153

http://poj.org/problem?id=2153 //* @author: 82638882@163.com import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int[] arr=new int[n]; HashMap< String,Integer> hs=new HashMap< String,Integer>(); String s=in.nextLine(); int tag=-1; for(int i=0;i< n;i++) { s=in.nextLine(); … Continue reading

## Poj Solution 2141

http://poj.org/problem?id=2141 //* @author popop0p0popo 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))); String code=scanner.nextLine(); String sent=scanner.nextLine(); String decode=""; for (int i=0;i< sent.length() ;i++ ){ decode=decode+getChar(sent.charAt(i),code); } System.out.print(decode); } public static char … Continue reading