Monthly Archives: January 2015

Poj Solution 3060

http://poj.org/problem?id=3060 #include <stdio.h> #include <memory.h> int m[1000][1000]; int sx[1000], sy[1000]; 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 | Leave a comment

Poj Solution 3058

http://poj.org/problem?id=3058 #include <stdio.h> #include <algorithm> #include <memory.h> using namespace std; int w1[1000000]; 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 | Leave a comment

Poj Solution 3055

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

Posted in poj | Leave a comment

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[0]); b=Integer.parseInt(ss[1]); p=new int[b+2][a+2]; for(int i=1;i<=b;i++) { … Continue reading

Posted in poj | Leave a comment

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[5][5]; … Continue reading

Posted in poj | Leave a comment

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 | Leave a comment

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 | Leave a comment

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 | Leave a comment

Poj Solution 3046

http://poj.org/problem?id=3046 #include <stdio.h> #include <memory.h> int c[1001]; int ans[1001][10000]; 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 | Leave a comment

Poj Solution 3045

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

Posted in poj | Leave a comment

Poj Solution 3044

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

Posted in poj | Leave a comment

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[32][32], int n, int m ) { int s[5][1000], sn[5] = {0}; int ans[5][1000] = { 0 }, i, j, k, ii, l, sum = 0; for( … Continue reading

Posted in poj | Leave a comment

Poj Solution 3042

http://poj.org/problem?id=3042 #include <stdio.h> #include <algorithm> #include <memory.h> using namespace std; int x[1001]; __int64 ans[1001][1001][2]; 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 | Leave a comment

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 | Leave a comment

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 | Leave a comment