# Monthly Archives: April 2010

## Poj Solution 1383

http://poj.org/problem?id=1383 #include"stdio.h" #include"memory.h" char map; bool sign; int max,bx,by,n,m; void init_sign() { int i,j; for(i=0;i<n;i++) for(j=0;j<m;j++) sign[i][j]=0; } void init() { scanf("%d %d",&m,&n); for(int i=0;i<n;i++) scanf("%s",map[i]); } inline int inmap(int x,int y) { return x>=0&&y>=0&&x<n&&y<m; } const int dx[]={0,0,1,-1},dy[]={1,-1,0,0}; void … Continue reading

Posted in poj | Comments Off on Poj Solution 1383

## Poj Solution 1371

http://poj.org/problem?id=1371 #include <iostream> #include <algorithm> #include <memory.h> using namespace std; int x, y, xn, yn, n, m; struct { int x1, x2, y1, y2; }ln; char map; bool init() { int i, j, l, r, u, d, k; cin >> … Continue reading

Posted in poj | Comments Off on Poj Solution 1371

## Poj Solution 1368

http://poj.org/problem?id=1368 #include<iostream> #include"memory.h" using namespace std; int set; int map; int n,m; int div(char c) {switch(c) {case ‘O’:return 0; case ‘F’:return 1; case ‘I’:return 2; default:return -1; } } void init() {int i,j,a;char c; memset(set,0,81*sizeof(int)); for(i=0;i<n*m;i++) {for(j=0;j<4;j++) {cin>>c;a[j]=div(c);} set[a][a][a][a]++; } … Continue reading

Posted in poj | Comments Off on Poj Solution 1368

## Poj Solution 1366

http://poj.org/problem?id=1366 //* @author: <strong>Yeming&nbsp;Hu</strong>&quot;cslittleye@gmail.com&quot; import java.util.*; import java.io.*; public class Main { public static BufferedInputStream bis; public static StringBuilder str; public static char[][] rules; public static StringBuilder[] words; public static int k; public static void main(String[] args) throws Exception { … Continue reading

Posted in poj | Comments Off on Poj Solution 1366

## Poj Solution 1365

http://poj.org/problem?id=1365 import java.util.*; import java.math.*; public class Main { /** * @param args */ static int pp; static int[] p = new int; static int[] w = new int; static boolean[] q = new boolean; static void init() { int … Continue reading

Posted in poj | Comments Off on Poj Solution 1365

## Poj Solution 1363

http://poj.org/problem?id=1363 import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int in[]=new int; int out[]=new int; int stack[]=new int; int n; int i,j; for(i=0;i< 1001;i++) in[i]=i+1; while(sc.hasNext()) { n=sc.nextInt(); if(n==0) break; while(true) { … Continue reading

Posted in poj | Comments Off on Poj Solution 1363

## Poj Solution 1362

http://poj.org/problem?id=1362 //* @author: <strong>Yeming&nbsp;Hu</strong>&quot;cslittleye@gmail.com&quot; import java.util.*; public class Main { public static final int max = 30; public static void main(String[] args) { int[] weights = new int[max]; int p = 2; for(int i = 0; i < max; i++) … Continue reading

Posted in poj | Comments Off on Poj Solution 1362

## Poj Solution 1354

http://poj.org/problem?id=1354 import java.io.BufferedInputStream; import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); while (scan.hasNext()) { int n = scan.nextInt(); if (n == -1) { break; } BigDecimal nn = … Continue reading

Posted in poj | Comments Off on Poj Solution 1354

## Poj Solution 1353

http://poj.org/problem?id=1353 //* @author: import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int a[]=new int,b[]=new int; int n,m,k; while(sc.hasNext()) { String s=sc.nextLine(); Scanner scan=new Scanner(s); scan.useDelimiter(","); n=scan.nextInt(); if(n==-1) break; m=scan.nextInt(); k=scan.nextInt(); for (int i=1;i<=n;i++) { if … Continue reading

Posted in poj | Comments Off on Poj Solution 1353

## Poj Solution 1351

http://poj.org/problem?id=1351 /* @author:zeropinzuo */ import java.io.*; import java.util.*; public class Main{ static Scanner cin; static long[] f,g; public static void main(String args[]){ cin = new Scanner(System.in); f = new long; g = new long; g=4; g=14; for(int i=3;i< 17;i++) g[i]=3*g[i-1]+2*g[i-2]; … Continue reading

Posted in poj | Comments Off on Poj Solution 1351

## Poj Solution 1350

http://poj.org/problem?id=1350 //* @author: <strong>Yeming&nbsp;Hu</strong>&quot;cslittleye@gmail.com&quot; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true) { String num = sc.next(); if(num.equals("-1")) { break; } System.out.println("N="+num+":"); if(num.length()!=4||(num.charAt(0)==num.charAt(1)&& num.charAt(1)==num.charAt(2)&& num.charAt(2)==num.charAt(3))) { System.out.println("No!!"); }else { int … Continue reading

Posted in poj | Comments Off on Poj Solution 1350

## Poj Solution 1344

http://poj.org/problem?id=1344 //* @author: import java.util.*; public class Main { static int value[][]=new int; static int ans,n; static void calc() { int i, j, temp, k, s; for( k=0; k< n-2; k++ ) { s = 10000000; for( i = k+1; … Continue reading

Posted in poj | Comments Off on Poj Solution 1344

## Poj Solution 1338

http://poj.org/problem?id=1338 //* @author mekarlos@gmail.com import java.util.Scanner; import java.util.Vector; public class Main { public static void main(String[] args) { Scanner scan=new Scanner(System.in); Vector< Long> v=new Vector< Long>(); v.add(new Long(1)); int i=0,j=0,k=0; while(v.size()< 1500){ v.add(Math.min(Math.min(v.get(i)*2, v.get(j)*3), v.get(k)*5)); if(v.get(v.size()-1).equals(v.get(v.size()-2))){v.remove(v.size()-1);} if(v.get(i)*2==v.get(v.size()-1))i++; else if(v.get(j)*3==v.get(v.size()-1))j++; else … Continue reading

Posted in poj | Comments Off on Poj Solution 1338