# Monthly Archives: May 2011

## Poj Solution 1804

http://poj.org/problem?id=1804 //* @author import java.util.*; public class Main { static int count=0; /** * @param args */ public static void main(String[] args) { Scanner in=new Scanner(System.in); String t=in.nextLine(); int tcase=Integer.parseInt(t); for(int j=1;j<=tcase;j++){ count=0; String str = in.nextLine(); String b[]=str.split("\s"); int … Continue reading

Posted in poj | Comments Off on Poj Solution 1804

## Poj Solution 1803

http://poj.org/problem?id=1803 #include"stdio.h" #include<iostream> #include"memory.h" #include"algorithm" using namespace std; int tree[1024*1024*2]; int stop[1024*1024*2]; long m[1024*1024*2]; long area; int x1,y1,x2,y2,key; long temp; void search(int s,long mj); void find(int xu,int yu,int xd,int yd,long s,long mj,int k) { if(xu>=x2||xd<=x1||yu>=y2||yd<=y1){return;} if(key){tree[s]++;} if(!key){tree[s]–;} if(xu>=x1&&yu>=y1&&xd<=x2&&yd<=y2) {if(!key)stop[s]–;else tree[s]–; … Continue reading

Posted in poj | Comments Off on Poj Solution 1803

## Poj Solution 1800

http://poj.org/problem?id=1800 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader re=new BufferedReader(new InputStreamReader(System.in) ); int T=Integer.parseInt(re.readLine()); for(int i=1;i<=T;i++) { int n=0,last=0; boolean[] use=new boolean[300010]; Set strset=new TreeSet(); … Continue reading

Posted in poj | Comments Off on Poj Solution 1800

## Poj Solution 1799

http://poj.org/problem?id=1799 //* @author popop0p0popo import java.util.*; import java.io.*; import java.text.*; public class Main{ public static void main(String[] args){ Scanner scanner=new Scanner(new BufferedReader(new InputStreamReader(System.in))); int n=scanner.nextInt(); double r,t; for (int i=0;i< n ;i++ ){ r=scanner.nextDouble(); t=scanner.nextDouble(); System.out.println("Scenario #"+(i+1)+":"); DecimalFormat df=new DecimalFormat("0.000"); … Continue reading

Posted in poj | Comments Off on Poj Solution 1799

## Poj Solution 1794

http://poj.org/problem?id=1794 /* @author: */ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int cas, k; cas=sc.nextInt(); for( k=1; k<=cas; k++ ) { int s1[]=new int[60010], s2[]=new int[60010]; int i, n, m, … Continue reading

Posted in poj | Comments Off on Poj Solution 1794

## Poj Solution 1789

http://poj.org/problem?id=1789 import java.io.PrintWriter; import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); //Scanner scn = new Scanner(Main.class.getResourceAsStream("in.dat")); PrintWriter out = new PrintWriter(System.out); int[][] table; String[] input; int n = 0; while(true){ n = … Continue reading

Posted in poj | Comments Off on Poj Solution 1789

## Poj Solution 1787

http://poj.org/problem?id=1787 #include<iostream> #include"memory.h" using namespace std; char set[10000]; int use[10000][4]; long total[10000]; int money[4]={1,5,10,25}; int limit[4],p; void doit() {int i,j,h,k; memset(set,0,10000*sizeof(char)); memset(use,0,10000*4*sizeof(int)); set[0]=1; total[0]=0; for(i=0;i<4;i++) for(j=0;j<=p-money[i];j++) {h=j+money[i]; if(set[j]&&(!set[h]||total[h]<total[j]+1)&&use[j][i]<limit[i]) {set[h]=1; for(k=0;k<4;k++)use[h][k]=use[j][k]; use[h][i]=use[j][i]+1; total[h]=total[j]+1; } } return; } int main() {int i; … Continue reading

Posted in poj | Comments Off on Poj Solution 1787

## Poj Solution 1786

http://poj.org/problem?id=1786 //* @author: SmilingWang import java.util.*; public class Main { public static void main(String[] args){ Scanner in = new Scanner(System.in); Map< String, Integer> map = new HashMap< String, Integer>(); map.put("N", 0); map.put("E", 1); map.put("S", 2); map.put("W", 3); String pos[] = … Continue reading

Posted in poj | Comments Off on Poj Solution 1786

## Poj Solution 1784

http://poj.org/problem?id=1784 /* @author: */ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int p[]=new int[202]; int q[]=new int[202]; int s[][]=new int[202][202]; int ans[][]=new int[202][202]; int sum[]=new int[202]; int n , i, … Continue reading

Posted in poj | Comments Off on Poj Solution 1784

## Poj Solution 1783

http://poj.org/problem?id=1783 #include<iostream> using namespace std; int prime[200],t[200],n; void doprime() {int i,j; n=1; prime[0]=2; for(i=3;i<1000;i++) {for(j=0;j<n;j++)if(i%prime[j]==0)break; if(j==n)prime[n++]=i; } } void fjie(int a[200],int s) {int i; for(i=0;i<200;i++)a[i]=0; for(i=0;i<n&&s>1;i++) while(s%prime[i]==0){a[i]++;s/=prime[i];} } int fn[101][200],fd[101][200],k,m,fdp[101][200],fnp[101][200]; int now[200]; void init() {int i,s,j,h; cin>>s; fjie(now,s); cin>>k; for(i=0;i<k;i++) … Continue reading

Posted in poj | Comments Off on Poj Solution 1783

## Poj Solution 1782

http://poj.org/problem?id=1782 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { /** * @param args */ public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub int i,j,n,cotinue; boolean is_first; String str; Scanner cin = new Scanner(System.in); … Continue reading

Posted in poj | Comments Off on Poj Solution 1782

## Poj Solution 1781

http://poj.org/problem?id=1781 //* @author: 82638882@163.com import java.io.*; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); while(true) { String s=in.readLine(); if(s.equals("00e0")) break; int a=(int)(((s.charAt(0)-‘0’)*10+s.charAt(1)-‘0’)*Math.pow(10, s.charAt(3)-‘0’)); s=Integer.toBinaryString(a); s=s.substring(1)+s.charAt(0); a=Integer.parseInt(s, 2); System.out.println(a); } … Continue reading

Posted in poj | Comments Off on Poj Solution 1781