# 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; int q[]=new int; int n,k; Scanner sc=new Scanner(System.in); n=sc.nextInt(); p=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

Posted in poj | Comments Off on Poj Solution 2182

## 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

Posted in poj | Comments Off on Poj Solution 2181

## 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, y1, x2, y2; int s2, lim2; int f; inline int distance( int i, int j ) { … Continue reading

Posted in poj | Comments Off on Poj Solution 2175

## 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, x, y, m; point p; void init( ) { int i, xx, yy; m = 0; n = 0; scanf( "%d … Continue reading

Posted in poj | Comments Off on Poj Solution 2173

## 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

Posted in poj | Comments Off on Poj Solution 2172

## 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

Posted in poj | Comments Off on Poj Solution 2163

## 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

Posted in poj | Comments Off on Poj Solution 2159

## Poj Solution 2155

http://poj.org/problem?id=2155 import java.util.Scanner; public class Main { private static int[][] matrix = new int; 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

Posted in poj | Comments Off on Poj Solution 2155

## 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

Posted in poj | Comments Off on Poj Solution 2153

## 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

Posted in poj | Comments Off on Poj Solution 2141

## Poj Solution 2140

http://poj.org/problem?id=2140 import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(cin.hasNext()) { int num = cin.nextInt(); int ways = 1; int index = num/2+1; for(int i = index; i > 1; i–) … Continue reading

Posted in poj | Comments Off on Poj Solution 2140

## Poj Solution 2138

http://poj.org/problem?id=2138 #include <iostream> #include <string> #include <vector> #include <cstring> #include <algorithm> using namespace std; int D; string ori; string v; int l; int longgest; bool visited; vector<string> vre; void search(string &str,int z) { bool Find = false; visited[z] = true; … Continue reading

Posted in poj | Comments Off on Poj Solution 2138