Monthly Archives: April 2012

Poj Solution 2137

http://poj.org/problem?id=2137 #include <iostream> #include <cmath> #include <cstdio> using namespace std; int map[2][50][202]; int len[202]; int N; int S; double calc(double x1,double y1,double x2,double y2) { return sqrt((x1 – x2) * (x1 – x2) + (y1 – y2) * (y1 – … Continue reading

Posted in poj | Leave a comment

Poj Solution 2135

http://poj.org/problem?id=2135 #include<iostream> #include"stdio.h" #include"vector" using namespace std; struct edge { int from; int to; int len; int opp; }; vector<edge> e[1010]; int from[1010],dis[1010],n,m; bool sign[1010]; edge *along[1010]; void dijstra() { int i,j,k,to; for(i=0;i<n;i++) { sign[i]=0; dis[i]=999999999; } sign[0]=0; from[0]=-1; dis[0]=0; … Continue reading

Posted in poj | Leave a comment

Poj Solution 2133

http://poj.org/problem?id=2133 #include<iostream> using namespace std; long a[140000],s[140000]; int main() { long i,n,m,j;long result; long begin[200],st,k,ss; char c; while(1) { cin>>m>>n; if(cin.fail())break; long h; h=(1<<16); result=0; for(j=0;j<m;j++) { cin>>c; result*=2; result+=c-‘0’; } for(i=0;i<n;i++) { begin[i]=0; for(j=0;j<m;j++) { cin>>c; begin[i]*=2; begin[i]+=c-‘0’; } … Continue reading

Posted in poj | Leave a comment

Poj Solution 2132

http://poj.org/problem?id=2132 //* @author:alpc12 import java.io.*; import java.util.*; import java.math.*; public class Main { static int N = 26; int n; int M; int[][] adj = new int[26][26]; boolean[] chk = new boolean[26]; boolean DFS(int K, int m) { chk[m] = … Continue reading

Posted in poj | Leave a comment

Poj Solution 2127

http://poj.org/problem?id=2127 /* @author: */ import java.util.*; public class Main { static int ans[][], xf[][], yf[][]; static int as[][], len[]; static public void main( String [] str ) throws Exception{ Scanner cin = new Scanner(System.in); int n = cin.nextInt(), m; int … Continue reading

Posted in poj | Leave a comment

Poj Solution 2126

http://poj.org/problem?id=2126 //* @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))); int n=Integer.parseInt(scanner.nextLine()); if (n< 2){ System.out.println("YES"); } else if (n==2){ int a=scanner.nextInt(); int b=scanner.nextInt(); int c=scanner.nextInt(); if (b*b-4*a*c>=0){ System.out.println("NO"); … Continue reading

Posted in poj | Leave a comment

Poj Solution 2121

http://poj.org/problem?id=2121 //* @author: 82638882@163.com import java.io.*; import java.util.*; public class Main { static String[] Num=new String[]{ "zero","one","two","three","four","five","six","seven","eight","nine","ten", "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen", "nineteen","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety", "hundred","thousand","million" }; public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); String s; while(true) { s=in.readLine(); … Continue reading

Posted in poj | Leave a comment

Poj Solution 2114

http://poj.org/problem?id=2114 #include <vector> #include <stdio.h> #include <algorithm> using namespace std; typedef pair< int, int > edge; vector< edge > e[10010]; int v[10010],s[10010]; int st[10010],sn; bool sign[10010]; int n; int find_root_search( int r, int f ) { int temp,i,j; v[r] = … Continue reading

Posted in poj | Leave a comment

Poj Solution 2112

http://poj.org/problem?id=2112 #include<iostream> using namespace std; #define null 0 const int size=1010; long dis[size][size],k,m,c,up,w[size][size]; int maxmatch(int n,int m,long w[][size],int *p) { int p_n[size]; int p_m[size]; bool sign[size]; int q[size],from[size],s,t; int i,j,link,now,h; for(i=0;i<n;i++)p_n[i]=-1; for(j=0;j<m;j++)p_m[j]=-1; for(i=0;i<n;i++) if(p_n[i]==-1) { for(j=0;j<m;j++)sign[j]=0; s=1;link=-1; from[0]=-1; q[0]=size-1; p_m[size-1]=i; … Continue reading

Posted in poj | Leave a comment

Poj Solution 2109

http://poj.org/problem?id=2109 import java.math.BigInteger; import java.util.Scanner; public class Main { static final BigInteger TWO = new BigInteger("2"); static final BigInteger ONE = BigInteger.ONE; public static void main(String[] args) { Scanner in = new Scanner(System.in); // k^n=p findK; BigInteger p; int n; … Continue reading

Posted in poj | Leave a comment

Poj Solution 2105

http://poj.org/problem?id=2105 import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int num = Integer.valueOf(cin.nextLine()).intValue(); for(int i = 0; i < num; i++) { String str, temp; int a,b,c,d = 0; StringBuffer sb … Continue reading

Posted in poj | Leave a comment

Poj Solution 2104

http://poj.org/problem?id=2104 //* @author: 82638882@163.com import java.io.*; import java.util.Arrays; class Main { public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); String[] ss=in.readLine().split(" "); int a=Integer.parseInt(ss[0]); int k=Integer.parseInt(ss[1]); my[] p=new my[a]; ss=in.readLine().split(" "); for(int i=0;i< a;i++) … Continue reading

Posted in poj | Leave a comment

Poj Solution 2103

http://poj.org/problem?id=2103 //* @author: import java.math.BigInteger; import java.util.Scanner; public class Main { static int oneNum[] = new int[65536]; static BigInteger arr[] = new BigInteger[20]; static int n; static BigInteger list[] = new BigInteger[65536]; public static void main(String[] args) { for(int i … Continue reading

Posted in poj | Leave a comment