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

Posted in poj | Leave a comment

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

Posted in poj | Leave a comment

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

Posted in poj | Leave a comment

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

Posted in poj | Leave a comment

Poj Solution 2676

http://poj.org/problem?id=2676 //* @author: 82638882@163.com import java.io.*; class Main { public static void main(String[] args) throws IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int cnt=Integer.parseInt(in.readLine()); while((cnt–)!=0) { int[][] p=new int[9][9]; for(int i=0;i< 9;i++) { for(int j=0;j< 9;j++) p[i][j]=in.read()-‘0’; in.readLine(); } … Continue reading

Posted in poj | Leave a comment

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

Posted in poj | Leave a comment

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

Posted in poj | Leave a comment

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

Posted in poj | Leave a comment

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

Posted in poj | Leave a comment

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

Posted in poj | Leave a comment

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

Posted in poj | Leave a comment

Poj Solution 2663

http://poj.org/problem?id=2663 import java.util.Scanner; import java.util.Arrays; public class Main{ static long S(int n) //S(n)=3*S(n-2)+2*(S(n-4)+S(n-6)+…+S(2)+S(0)) { long s; int i; if(n==0)return 1; else { s=3*S(n-2); for(i=n-4;i>=0;i-=2) { s+=2*S(i); } return s; } } public static void main(String args[]){ Scanner sc=new Scanner(System.in); int … Continue reading

Posted in poj | Leave a comment

Poj Solution 2661

http://poj.org/problem?id=2661 //* @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; a-=1960; a/=10; a=(int)Math.pow(2, a+2); double k=0; int n=2; while(k< a) { k+=Math.log(n)/Math.log(2); n++; } System.out.println(n-2); … Continue reading

Posted in poj | Leave a comment