# Monthly Archives: January 2015

## Poj Solution 3060

http://poj.org/problem?id=3060 #include <stdio.h> #include <memory.h> int m; int sx, sy; int main() { int t, n, i, j, d, a, b, best; scanf( "%d", &t ); while( t– ) { scanf( "%d%d", &d, &n ); best = 99999999; memset( m, … Continue reading

Posted in poj | Comments Off on Poj Solution 3060

## Poj Solution 3058

http://poj.org/problem?id=3058 #include <stdio.h> #include <algorithm> #include <memory.h> using namespace std; int w1; int main() { int t, i, j, m; char c, temp; scanf( "%d", &t ); getchar(); while( t– ) { m = 0; while( 1 ){ c = … Continue reading

Posted in poj | Comments Off on Poj Solution 3058

## Poj Solution 3055

http://poj.org/problem?id=3055 #include <stdio.h> int main() { int n, i, j, k; char mm, *w1 = &mm, *w2 = &mm, *t; int a, b, temp; bool key; scanf( "%d", &n ); while( n– ) { scanf( "%s %s", w1, w2 ); … Continue reading

Posted in poj | Comments Off on Poj Solution 3055

## Poj Solution 3051

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

Posted in poj | Comments Off on Poj Solution 3051

## Poj Solution 3050

http://poj.org/problem?id=3050 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Set; public class Main { static Set<Integer> set; static int[][] a; public static void main(String[] args) throws IOException { BufferedReader read = new BufferedReader(new InputStreamReader( System.in)); a = new int; … Continue reading

Posted in poj | Comments Off on Poj Solution 3050

## Poj Solution 3049

http://poj.org/problem?id=3049 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { static final int N = 20; static int n,l; static String ans; static char word[] = new char[N]; static char ansp[] = new char[N]; public static void main(String … Continue reading

Posted in poj | Comments Off on Poj Solution 3049

## Poj Solution 3048

http://poj.org/problem?id=3048 import java.util.Scanner; import java.util.Arrays; public class Main{ public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n,mx=-1,tag=-1,i,v; n=sc.nextInt(); while((n–)!=0) { v=sc.nextInt(); int u=v; int maxx=1; if(v%2==0) { maxx=2; while(v%2==0)v/=2; } for(i=3;i*i<=v;i+=2) { if(v%i==0) { maxx=i; while(v%i==0)v/=i; } } … Continue reading

Posted in poj | Comments Off on Poj Solution 3048

## Poj Solution 3047

http://poj.org/problem?id=3047 //* @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 a[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; String s[]={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}; int n,y,m,d,t; y=sc.nextInt(); m=sc.nextInt(); d=sc.nextInt(); t=(y-1)*365; for (int i=1;i< y;i++) if ((i%4==0&&i%100!=0)||(i%400==0)) … Continue reading

Posted in poj | Comments Off on Poj Solution 3047

## Poj Solution 3046

http://poj.org/problem?id=3046 #include <stdio.h> #include <memory.h> int c; int ans; int main() { int i, j, k, sum, n, a, t, left, right; scanf( "%d%d%d%d", &n, &a, &left, &right ); if( a > 10000 ) while( printf( "asdf" ) ); for( … Continue reading

Posted in poj | Comments Off on Poj Solution 3046

## Poj Solution 3045

http://poj.org/problem?id=3045 #include <stdio.h> #include <algorithm> using namespace std; struct cow { int sum, w, s; }c; int n; bool cmp( cow a, cow b ) { return a.sum < b.sum; }; bool check( int k ) { int sum = … Continue reading

Posted in poj | Comments Off on Poj Solution 3045

## Poj Solution 3044

http://poj.org/problem?id=3044 #include <stdio.h> #include <algorithm> using namespace std; int id; int h; bool sign; int temp; int *next = &temp; int *pri = &temp; bool cmp( int a, int b ) { return h[a] > h[b]; } int main() { … Continue reading

Posted in poj | Comments Off on Poj Solution 3044

## Poj Solution 3043

http://poj.org/problem?id=3043 #include <stdio.h> #define max(a,b) ((a)>(b)?(a):(b)) int clac( char *w, int len, char map, int n, int m ) { int s, sn = {0}; int ans = { 0 }, i, j, k, ii, l, sum = 0; for( … Continue reading

Posted in poj | Comments Off on Poj Solution 3043

## Poj Solution 3042

http://poj.org/problem?id=3042 #include <stdio.h> #include <algorithm> #include <memory.h> using namespace std; int x; __int64 ans; int main() { int i, j, n, k; scanf( "%d%d", &n, &k ); for( i=0; i<n; i++ ) { scanf( "%d", &x[i] ); } x[n] = … Continue reading

Posted in poj | Comments Off on Poj Solution 3042

## Poj Solution 3041

http://poj.org/problem?id=3041 //* @author: 82638882@163.com import java.util.Scanner; public class Main { static int a,b; static int[][] map; static int[] used; static int[] match; public static void main(String[] args) { Scanner in=new Scanner(System.in); a=in.nextInt(); b=in.nextInt(); map=new int[a+1][a+1]; for(int i=0;i< b;i++) map[in.nextInt()][in.nextInt()]=1; match=new … Continue reading

Posted in poj | Comments Off on Poj Solution 3041

## Poj Solution 3039

http://poj.org/problem?id=3039 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ public static void main(String args[]) { Scanner sc=new Scanner(System.in); double a,b,e,min; int c,d,u=0,v=0; a=sc.nextDouble(); b=sc.nextDouble(); a=a/b; c=d=1; min=32768; while(c< 32768&&d<32768) { e=c*1.0/d*1.0; if(e==a){ d++; continue; } if(e>a){ if(e-a< min){ … Continue reading

Posted in poj | Comments Off on Poj Solution 3039