Monthly Archives: September 2013

Poj Solution 2564

http://poj.org/problem?id=2564 #include "stdio.h" #include "string.h" #include "vector" using namespace std; const int size = 25000; vector< char* > s1[18][26]; vector< char* > s2[18][26]; char w[size][17]; int ans[size],len[size]; bool check( char *a, char *b ) { int la = len[ ( … Continue reading

Posted in poj | Leave a comment

Poj Solution 2563

http://poj.org/problem?id=2563 #include<iostream> using namespace std; int d=0,m=0; inline void data(long g) {cout<<g/10000<<"-"; g%=10000;if(g/1000==0)cout<<‘0’; cout<<g/100<<"-"; g%=100;if(g/10==0)cout<<‘0’; cout<<g<<‘ ‘; } inline void demerit() {cout<<d<<" demerit point(s)."<<endl;} inline void merit() {cout<<m<<" merit point(s)."<<endl;} inline void none() {cout<<"No merit or demerit points."<<endl;} int main() … Continue reading

Posted in poj | Leave a comment

Poj Solution 2562

http://poj.org/problem?id=2562 //* @author ������&lt;hongxp11@163.com&gt; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(true) { String first = in.next(); String second = in.next(); //System.out.println(first.length()+" "+second.length()); if(first.equals("0") && second.equals("0")) { break; } int … Continue reading

Posted in poj | Leave a comment

Poj Solution 2560

http://poj.org/problem?id=2560 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ static double INF=99999999.0; public static void main(String args[]) { Scanner sc=new Scanner(System.in); double p[][]=new double[101][101]; double ax[]=new double[101]; double ay[]=new double[101]; double dis[]=new double[101]; boolean used[]=new boolean[101]; int n,i,j; … Continue reading

Posted in poj | Leave a comment

Poj Solution 2559

http://poj.org/problem?id=2559 //* @author: 82638882@163.com import java.io.*; public class Main { static int[] p,b,c; static int a; public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); while(true) { String[] ss=in.readLine().split(" "); a=Integer.parseInt(ss[0]); if(a==0) break; p=new int[a+2]; … Continue reading

Posted in poj | Leave a comment

Poj Solution 2557

http://poj.org/problem?id=2557 #include<iostream> #include"string.h" using namespace std; int width[210],n; int ans[210][210]; char fold[210]; bool init() { int i,j; cin>>fold; if(cin.fail())return 0; n=strlen(fold); for(i=0;i<n;i++) { for(j=1;i+j<n&&i-j>=0&&fold[i+j]+fold[i-j]==’A’+’V’;j++) ; width[i]=j; } return 1; } inline int get_ans(int a,int b) { return (a>b)?0:ans[a][b]; } void … Continue reading

Posted in poj | Leave a comment

Poj Solution 2556

http://poj.org/problem?id=2556 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); while(in.hasNext()) { String s=in.next(); System.out.println("300 420 moveto"); System.out.println("310 420 lineto"); int b=0; int x=310; int y=420; for(int i=0;i< s.length();i++) { char … Continue reading

Posted in poj | Leave a comment

Poj Solution 2555

http://poj.org/problem?id=2555 /* @author:zeropinzuo */ import java.io.*; import java.util.*; import java.text.DecimalFormat; public class Main{ static Scanner cin; static double ci = 2.09, cw = 4.19; static double em = 335; public static void main(String args[]){ cin = new Scanner(System.in); while(run()) ; … Continue reading

Posted in poj | Leave a comment

Poj Solution 2553

http://poj.org/problem?id=2553 #include"stdio.h" #include"memory.h" #include"list" using namespace std; long sign[5010]; long st[5010],s; long ok[5010]; long v; list<int> out[5000],in[5000]; void find(int a) {list<int>::iterator iter; sign[a]=1; for(iter=out[a].begin();iter!=out[a].end();iter++) { if(sign[*iter]==0)find(*iter); } st[s++]=a; } int sink; void find_too(int a) {list<int>::iterator iter; sign[a]=sink; for(iter=in[a].begin();iter!=in[a].end();iter++) { if(sign[*iter]!=0&&sign[*iter]!=sink)ok[sign[*iter]]=1; … Continue reading

Posted in poj | Leave a comment

Poj Solution 2552

http://poj.org/problem?id=2552 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { ArrayList< Integer> a=new ArrayList< Integer>(); for(int i=2;i< 35000;i++) a.add(i); int count=0; while(count< a.size()) { for(int i=count+a.get(count);i< a.size();i+=a.get(count)) a.set(i, 0); for(int i=0;i< a.size();i++) if(a.get(i)==0){ a.remove(i); … Continue reading

Posted in poj | Leave a comment

Poj Solution 2551

http://poj.org/problem?id=2551 //* @author ������&lt;hongxp11@163.com&gt; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()) { int input = in.nextInt(); int result = 1; int begin = 1; while(true) { if(begin % input … Continue reading

Posted in poj | Leave a comment

Poj Solution 2549

http://poj.org/problem?id=2549 import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.Set; /** * Accepted. * * @author Administrator * */ public class Main { private static Set< Long> set = new HashSet< Long>(); private … Continue reading

Posted in poj | Leave a comment

Poj Solution 2546

http://poj.org/problem?id=2546 //* @author: ccQ.SuperSupper import java.io.*; import java.text.DecimalFormat; import java.util.*; import java.math.*; public class Main { /** * @param args */ static double min(double a,double b) { if(a>b) return b; return a; } static double max(double a,double b) { if(a>b) … Continue reading

Posted in poj | Leave a comment