Monthly Archives: April 2010

Poj Solution 1383

http://poj.org/problem?id=1383 #include"stdio.h" #include"memory.h" char map[1100][1100]; bool sign[1100][1100]; 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 | Leave a comment

Poj Solution 1371

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

Posted in poj | Leave a comment

Poj Solution 1368

http://poj.org/problem?id=1368 #include<iostream> #include"memory.h" using namespace std; int set[3][3][3][3]; int map[7][7][4]; 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[4];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[0]][a[1]][a[2]][a[3]]++; } … Continue reading

Posted in poj | Leave a comment

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 | Leave a comment

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[30000]; static int[] w = new int[30000]; static boolean[] q = new boolean[35000]; static void init() { int … Continue reading

Posted in poj | Leave a comment

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[1001]; int out[]=new int[1001]; int stack[]=new int[1001]; 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 | Leave a comment

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 | Leave a comment

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 | Leave a comment

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[200],b[]=new int[200]; 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 | Leave a comment

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[17]; g = new long[17]; g[1]=4; g[2]=14; for(int i=3;i< 17;i++) g[i]=3*g[i-1]+2*g[i-2]; … Continue reading

Posted in poj | Leave a comment

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 | Leave a comment

Poj Solution 1344

http://poj.org/problem?id=1344 //* @author: import java.util.*; public class Main { static int value[][]=new int[50][50]; 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 | Leave a comment

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 | Leave a comment