# Monthly Archives: March 2014

## Poj Solution 2680

http://poj.org/problem?id=2680 import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { int n; BigInteger two,ans; Scanner cin = new Scanner (System.in); while(cin.hasNext()) { n = cin.nextInt(); two = BigInteger.valueOf(2); ans = two; if(n%2==0) { … Continue reading

## Poj Solution 2679

http://poj.org/problem?id=2679 #include <stdio.h> #include <vector> #include <memory.h> using namespace std; const int size = 1110; struct edge { int len; int fee; edge *next; }; edge e[size][size]; edge *link[size]; bool sign[size]; int m, n, begin, end; int fee[size]; void search( … Continue reading

## Poj Solution 2678

http://poj.org/problem?id=2678 #include<iostream> #include"stdio.h" #include"math.h" #include<vector> #include<algorithm> using namespace std; const double eps=1e-8; const int size = 1010; //////////////////////////////// typedef double Type;/*????????*/ //////////////////////////////// struct point { Type x,y; point(){x=y=0;} point(Type x,Type y):x(x),y(y){;} bool operator==(point &a){return x==a.x&&y==a.y;} }; //???? inline Type cheng(point … Continue reading

## Poj Solution 2677

http://poj.org/problem?id=2677 #include <stdio.h> #include <memory.h> #include <math.h> struct point { double x, y; }; double dis( point &a, point &b ) { return sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ); } double s[1010][1010]; point p[1010]; int main( ) { int n, i, … Continue reading

## Poj Solution 2675

http://poj.org/problem?id=2675 #include <stdio.h> #include <algorithm> #include <string.h> #include <math.h> const double eps = 1e-6; using namespace std; double v[70000]; int id[70000], s[70000], l[70000]; bool cmp( int a, int b ) { return v[a]*l[b] < v[b]*l[a]; } int main( ) { … Continue reading

## Poj Solution 2673

http://poj.org/problem?id=2673 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ public static void main(String args[]) { Scanner sc=new Scanner(System.in); int total,per,t,max; total=sc.nextInt(); per=sc.nextInt(); t=sc.nextInt(); max=total; while((t–)!=0) { int dis,speed,fir,sum; dis=sc.nextInt(); speed=sc.nextInt(); if(speed==0) continue; if(speed>=dis) max=0; fir=dis/speed; if(dis%speed==0) fir–; sum=fir+(total-fir)/2; … Continue reading

## Poj Solution 2672

http://poj.org/problem?id=2672 #include <stdio.h> #include <string.h> #include <memory.h> //�����ͼ���ƥ�䣬 //����ƥ�����wΪn*m�ڽӾ���,p������X( |X|=n )ƥ��Ķ����� #define null 0 const int size=30; bool maxmatch(int n,int m,bool 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; … Continue reading

## Poj Solution 2669

http://poj.org/problem?id=2669 #include <stdio.h> #include <memory.h> #include <vector> #include <algorithm> using namespace std; double dis[100][100]; int n, m; bool e[100][100]; int son[100]; double len[100]; bool sign [100]; int v2[100], v[100], vn2, vn; int calc2( int a, int f ) { int … Continue reading

## Poj Solution 2665

http://poj.org/problem?id=2665 //* @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 s,n,tn; while (true){ s=scanner.nextInt(); n=scanner.nextInt(); if (s==0&&n==0){ break; } tn=s+1; for (int i=0;i< n ;i++ ){ tn=tn+scanner.nextInt()-scanner.nextInt()-1; } … Continue reading

## Poj Solution 2664

http://poj.org/problem?id=2664 //* @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; boolean bb=true; int b=in.nextInt(); HashSet< Integer> hs=new HashSet< Integer>(); while((a–)!=0) hs.add(in.nextInt()); while((b–)!=0) { int c=in.nextInt(); … Continue reading