# Monthly Archives: May 2015

## Poj Solution 3132

http://poj.org/problem?id=3132 //* @author: import java.io.BufferedInputStream; import java.util.ArrayList; import java.util.Scanner; public class Main { static ArrayList< Integer> primes = Prime.getPrimes(1120); public static void main(String[] args) { int[][] f = new int[1140][1140]; Scanner scan = new Scanner(new BufferedInputStream(System.in)); f[0][0] = 1; for … Continue reading

## Poj Solution 3130

http://poj.org/problem?id=3130 #include <stdio.h> #include <math.h> #include <memory.h> #include <algorithm> using namespace std; 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 a,point b,point c) {return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);} inline Type … Continue reading

## Poj Solution 3129

http://poj.org/problem?id=3129 #include <stdio.h> #include <math.h> struct point { double x, y, z; }; double dcheng( point &a, point &b ) { return a.x*b.x+a.y*b.y+a.z*b.z; } point p[500], q[50]; double r[50]; int main( ) { int i, j, n, m, counter; double … Continue reading

## Poj Solution 3128

http://poj.org/problem?id=3128 /* @author: */ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t, i, c, j; char w[]=new char[100]; boolean s[]=new boolean[100]; int ans[]=new int[100]; t=sc.nextInt(); while(( t– )!=0) { … Continue reading

## Poj Solution 3126

http://poj.org/problem?id=3126 import java.io.BufferedInputStream; import java.util.LinkedList; import java.util.Scanner; public class Main { static boolean[] isPrime = Prime.getPrimes(10000); public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); int cas = scan.nextInt(); for (int i = 1; i <= cas; … Continue reading

## Poj Solution 3125

http://poj.org/problem?id=3125 import java.io.BufferedInputStream; import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; /** * @author NC * poj3125 */ public class Main { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); int cas = scan.nextInt(); for (int i = … Continue reading

## Poj Solution 3122

http://poj.org/problem?id=3122 /* @author: */ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int r[]=new int[10000], t, i, n, f, count; double a, b, c; t=sc.nextInt(); while(( t–)!=0 ) { n=sc.nextInt(); f=sc.nextInt(); … Continue reading

## Poj Solution 3119

http://poj.org/problem?id=3119 #include <stdio.h> #include <math.h> #include <stdlib.h> int sx[65536], sy[65536]; int c, r, to; const int dx[] = { 0, 1, 0, -1 }, dy[] = { 1, 0, -1, 0 }; void next( int &x, int &y ) { … Continue reading

## Poj Solution 3117

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