# Monthly Archives: April 2013

## Poj Solution 2459

http://poj.org/problem?id=2459 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { static final int N = 2000+10; static int DP[] = new int[N]; public static void main(String[]args) throws Exception{ int n,F1,F2,Day,i,sum,a,b,j; //Scanner cin = new Scanner(new FileInputStream("input.txt")); Scanner cin … Continue reading

Posted in poj | Comments Off on Poj Solution 2459

## Poj Solution 2458

http://poj.org/problem?id=2458 #include "stdio.h" char map[6][6]; bool sign[6][6]; int flag[6][6]; bool inline inmap( int x, int y ) { return 0<=x&&x<5&&0<=y&&y<5; } int dx[]={ 0,-1, 0, 1}; int dy[]={-1, 0, 1, 0}; int ans; int reach; int visit; void find( int … Continue reading

Posted in poj | Comments Off on Poj Solution 2458

## Poj Solution 2457

http://poj.org/problem?id=2457 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { static final int N = 10000+10; static int meat[] = new int[N],pre[] = new int[N],n,K; static Vector Graph[] = new Vector[N]; static Queue que = new LinkedList<Integer>(); static … Continue reading

Posted in poj | Comments Off on Poj Solution 2457

## Poj Solution 2456

http://poj.org/problem?id=2456 #include <stdio.h> #include <algorithm> using namespace std; int pos[100000], n, cc; bool check( int l ) { int i, r, j; for( r=cc-1,i=0,j=1; j<n && r; j++ ) { if( pos[j]-pos[i]>=l ) { r–; i=j; } } return r … Continue reading

Posted in poj | Comments Off on Poj Solution 2456

## Poj Solution 2454

http://poj.org/problem?id=2454 #include"stdio.h" #include"memory.h" #include"algorithm" #include"stdlib.h" using namespace std; typedef pair<int,int> city; city c[180]; int n, k; void init() { int i; scanf( "%d", &n ); k = n; n *= 3; for( i=0; i<n; i++ ) { scanf( "%d", &c[i].first … Continue reading

Posted in poj | Comments Off on Poj Solution 2454

## Poj Solution 2453

http://poj.org/problem?id=2453 import java.util.Scanner; public class Main { /** * 获得一个Integer对应的二进制中1的个数 * @param i * @return sum */ public static int getSum(int i) { int sum = 0; while (i > 0) { i = i & (i – 1); ++sum; … Continue reading

Posted in poj | Comments Off on Poj Solution 2453

## Poj Solution 2452

http://poj.org/problem?id=2452 //* @author: import java.util.*; public class Main { static public void main( String [] str ) throws Exception{ Scanner sc = new Scanner(System.in); int i, j, h, ans; while(sc.hasNext()) { int n=sc.nextInt(); int s[]=new int[n]; for( i=0; i< n; … Continue reading

Posted in poj | Comments Off on Poj Solution 2452

## Poj Solution 2450

http://poj.org/problem?id=2450 //* @author: import java.util.*; import java.math.*; public class Main { static int gcd(int a,int b) { int c; while( (a%=b) != 0 ) { c=b; b=a; a=c; } return b; } static int a,b,c,d,n,m,p,q; static int t[] = new … Continue reading

Posted in poj | Comments Off on Poj Solution 2450

## Poj Solution 2449

http://poj.org/problem?id=2449

Posted in poj | Comments Off on Poj Solution 2449

## Poj Solution 2447

http://poj.org/problem?id=2447 #include<stdlib.h> #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; typedef unsigned __int64 u64; #define MAX 30 #define MAXN 5 u64 len, dig, limit; u64 factor[MAXN]; u64 mod(u64 a, u64 b, u64 n){ if(!a)return 0; else return ( ((a&dig)*b)%n + (mod(a>>len,b,n)<<len)%n )%n; … Continue reading

Posted in poj | Comments Off on Poj Solution 2447

## Poj Solution 2446

http://poj.org/problem?id=2446 #include<iostream> #include<string> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; const int MAXN=1050; int link[MAXN]; int total; bool vist[33][33]; //用来标记那些位置有洞 bool usedif[MAXN]; bool mat[MAXN][MAXN]; bool Can(int t) { int i; for(i=0;i<total;i++) if(mat[t][i]&&!usedif[i]) { usedif[i]=true; if(link[i]==-1||Can(link[i])) { link[i]=t; return true; … Continue reading

Posted in poj | Comments Off on Poj Solution 2446

## Poj Solution 2445

http://poj.org/problem?id=2445 #include"stdio.h" #include"algorithm" using namespace std; int l[1500][1500],r[1500][1500],u[1500][1500],d[1500][1500],lu[1500][1500],rd[1500][1500]; int n; inline int max(int a,int b) { return a>b?a:b; } inline int min(int a,int b) { return a<b?a:b; } bool init() { int i,j,m,k,a,b; char c; if(scanf("%d",&n)!=1) return 0; scanf("%d",&m); for(i=0;i<n;i++) … Continue reading

Posted in poj | Comments Off on Poj Solution 2445

## Poj Solution 2443

http://poj.org/problem?id=2443 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; class Set{ void init(){ for(int i=0;i< 35;++i) state[i] = 0; } void get_int(int cnt){ int k = cnt/30; int posi = cnt%30; state[k]|=dir[posi]; } int dir[] = {1,1<<1,1<<2,1<<3,1<<4,1<<5,1<<6,1<<7,1<<8,1<<9,1<<10,1<<11,1<<12,1<<13,1<<14, 1<<15,1<<16,1<<17,1<<18,1<<19,1<<20,1<<21,1<<22,1<<23,1<<24,1<<25,1<<26,1<<27, 1<<28,1<<29,1<<30,1<<31}; int state[] … Continue reading

Posted in poj | Comments Off on Poj Solution 2443

## Poj Solution 2441

http://poj.org/problem?id=2441 //* @author: /* ����: N��ţ��M�������(barn)��ÿ��ţ���м����Լ�ϲ����barn��Ҫ��Ϊÿ��ţ����һ��barn�� ʹ��ÿ��ţ��ֵ���barn�����Լ�ϲ���ģ���ÿ��barn�v�ֻ������һ��ţ����Ϸ��ķ��䷽��������N,M<=20�� ����: ��һ����N��M(1<=N<=20, 1<=M<=20); ����4��N��: ��i�еĵ�һ�������ǵ�i��ţϲ����barn��,���������ǵ�i��ţϲ����barn���(1<=i<=N) ���: ���䷽�������� */ import java.util.*; public class Main { static final int N=20+2; static final int M=1<< 20+1; public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n, … Continue reading

Posted in poj | Comments Off on Poj Solution 2441

## Poj Solution 2440

http://poj.org/problem?id=2440 import java.util.Scanner; public class Main { public static int[][] org; public static int[][] m; public static int[][] f = new int[4][1]; public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(cin.hasNext()) { int n = cin.nextInt(); if(test(n)) … Continue reading

Posted in poj | Comments Off on Poj Solution 2440