# Monthly Archives: August 2009

## Poj Solution 1132

http://poj.org/problem?id=1132 #include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #define NMAX 33 #define INF 1000000001 int xp[4]={0,1,0,-1},yp[4]={1,0,-1,0}; int dx[4]={0,0,-1,-1},dy[4]={0,-1,-1,0}; int stx,sty; int map[NMAX][NMAX]; char in[NMAX*NMAX]; int set(char t) { switch(t) { case ‘N’:return 0; case ‘E’:return 1; case ‘S’:return 2; case ‘W’:return 3; } … Continue reading

Posted in poj | Comments Off on Poj Solution 1132

## Poj Solution 1131

http://poj.org/problem?id=1131 import java.io.*; import java.util.*; import java.math.*; public class Main{ public static void main(String[] args){ Scanner cin=new Scanner(System.in); BigDecimal temp,sum,ans,num; String str; int i,len; while(cin.hasNext()){ str=cin.next(); len=str.length(); temp=BigDecimal.valueOf(8.0); sum=BigDecimal.ONE; ans=BigDecimal.ZERO; for(i=2;i< len;i++) { int val=str.charAt(i)-‘0’; num=BigDecimal.valueOf(val); sum=sum.multiply(temp); ans=ans.add(num.divide(sum)); } System.out.printf("%s … Continue reading

Posted in poj | Comments Off on Poj Solution 1131

## Poj Solution 1129

http://poj.org/problem?id=1129 import java.util.*; import java.io.*; /* *����������ŵ7��䡣��һ������ͼ��Ϊÿ����������ɫ��Ҫ���������ڵĶ�����ɫ��ͬ�� * �����ٵ���ɫ���Ƕ���? *������������ɫ���?ֱ��ö����ɫ��+DFS������DFS�Ǳ�fö��ÿ�����ɫ���Ա��ҵ�һ����н⡣ */ public class Main{ public static int[][] g=new int[26][26]; public static int solve(int n){ int i,j,cnum; boolean tag=true; // �ޱ�ͼֻ��1ɫ���� for(i=0;i< n && tag;i++){ for(j=i+1;j< n && tag;j++){ if(g[i][j]==1) tag=false; … Continue reading

Posted in poj | Comments Off on Poj Solution 1129

## Poj Solution 1126

http://poj.org/problem?id=1126 import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { Scanner s = new Scanner(System.in); String sentence = null; int count; char ch; while ((sentence = s.nextLine()) != null) { count = … Continue reading

Posted in poj | Comments Off on Poj Solution 1126

## Poj Solution 1122

http://poj.org/problem?id=1122 //* @author: 82638882@163.com import java.util.Arrays; import java.util.Scanner; public class Main { static final int Inf=9999999; public static void main(String[] args) { Scanner in=new Scanner(System.in); int a=in.nextInt(); int[][] p=new int[a][a]; for(int i=0;i< a;i++) for(int j=0;j< a;j++) p[i][j]=in.nextInt(); int loc =in.nextInt()-1; … Continue reading

Posted in poj | Comments Off on Poj Solution 1122

## Poj Solution 1120

http://poj.org/problem?id=1120 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ int map[][]=new int[22][22]; int d[]=new int[16]; char code[]={‘.’,’!’,’X’,’#’}; int sum(int i,int j){ return map[i][j]+map[i-1][j]+map[i+1][j]+map[i][j-1]+map[i][j+1]; } public void doIt(){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int i=0;i< 16;i++) d[i]=sc.nextInt(); for(int i=1;i<=20;i++) … Continue reading

Posted in poj | Comments Off on Poj Solution 1120

## Poj Solution 1119

http://poj.org/problem?id=1119 import java.io.BufferedReader; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.HashMap; import java.util.Map; public class Main{ private static String convertString(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { if (s.charAt(i) >= … Continue reading

Posted in poj | Comments Off on Poj Solution 1119

## Poj Solution 1118

http://poj.org/problem?id=1118 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); while(true) { int a=in.nextInt(); if(a==0)break; int[] arrx=new int[a]; int[] arry=new int[a]; for(int i=0;i< a;i++) { arrx[i]=in.nextInt(); arry[i]=in.nextInt(); } int max=0; for(int … Continue reading

Posted in poj | Comments Off on Poj Solution 1118

## Poj Solution 1113

http://poj.org/problem?id=1113 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { class Point { int x; int y; public Point(int x, int y) { this.x = x; this.y = y; } } public static void main(String[] args) throws IOException { … Continue reading

Posted in poj | Comments Off on Poj Solution 1113

## Poj Solution 1112

http://poj.org/problem?id=1112 #include <vector> #include <algorithm> #include <stdio.h> #include <memory.h> #include <math.h> using namespace std; vector<int> unknow[100]; vector< pair<int,int> > s; int sign[100]; bool e[100][100]; int flag[110][110]; int a, b, an, bn; bool search( int k, int key ) { int … Continue reading

Posted in poj | Comments Off on Poj Solution 1112

## Poj Solution 1111

http://poj.org/problem?id=1111 //* @author: 82638882@163.com import java.io.*; class Main { static int cnt; static char[][] map; static int[][] bool; public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); while(true) { cnt=0; String[] ss=in.readLine().split(" "); int row=Integer.parseInt(ss[0]); … Continue reading

Posted in poj | Comments Off on Poj Solution 1111

## Poj Solution 1110

http://poj.org/problem?id=1110 #include "stdio.h" char map[80][10][80]; int n; int main( ) { int n, r, c, i, j, k, l, test = 0; while( scanf( "%d%d%d", &n, &r, &c ) == 3 ) { if( n == 0 ) break; for( … Continue reading

Posted in poj | Comments Off on Poj Solution 1110