Monthly Archives: July 2011

Poj Solution 1861

http://poj.org/problem?id=1861 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; class Edge implements Comparable{ int u,v,disten; Edge(){}; void set(int u,int v,int disten){ this.u = u; this.v = v; this.disten = disten; } public int compareTo(Object obj){ Edge temp = (Edge)obj; if(this.disten>temp.disten) return … Continue reading

Posted in poj | Comments Off on Poj Solution 1861

Poj Solution 1860

http://poj.org/problem?id=1860 //* @author import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; //���·��bellman_ford public class Main { Scanner cin = new Scanner(System.in); int n; int m; int s; double v; Edge[] rate; Edge[] commission; double[] value; public static final double EPS … Continue reading

Posted in poj | Comments Off on Poj Solution 1860

Poj Solution 1859

http://poj.org/problem?id=1859 #include <stdio.h> #include <algorithm> using namespace std; struct pairs { int first, second; }p[20100]; bool cmp( const pairs& a, const pairs& b ) { return a.first<b.first || a.first==b.first&&a.second<b.second; } int main( ) { int n, i, sx, sy; while( … Continue reading

Posted in poj | Comments Off on Poj Solution 1859

Poj Solution 1852

http://poj.org/problem?id=1852 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { /** * @param args */ static int max(int a,int b) { if(a>b) return a; return b; } static int min(int a,int b) { if(a>b) return b; return a; … Continue reading

Posted in poj | Comments Off on Poj Solution 1852

Poj Solution 1850

http://poj.org/problem?id=1850 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); String s=in.next(); boolean bb=false; for(int i=0;i< s.length()-1;i++) { if(s.charAt(i)-s.charAt(i+1)>=0) { System.out.println(0); bb=true; break; } } if(bb) System.exit(0); int l=s.length(); long ans=0; … Continue reading

Posted in poj | Comments Off on Poj Solution 1850

Poj Solution 1845

http://poj.org/problem?id=1845 import java.util.*; public class Main { static long modPow(long a,long n) { long MOD=9901; if (n==1) return a%MOD; long tmp=modPow(a,n>>1); tmp=tmp*tmp%MOD; if ((n&1)==1) tmp=tmp*a%MOD; return tmp; } static long myPow(long a,long n) { if (n==0) return 1; long ans=modPow(a,(n>>1)+1); … Continue reading

Posted in poj | Comments Off on Poj Solution 1845

Poj Solution 1844

http://poj.org/problem?id=1844 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int sun=in.nextInt(); int sum=0; int i; for(i=1;i< 9999;i++) { sum+=i; if (sum>=sun)break; } if((sum-sun)%2==0) System.out.println(i); else if((sum-sun)%2==1&&i%2==1) System.out.println(i+2); else if((sum-sun)%2==1&&i%2==0) System.out.println(i+1); … Continue reading

Posted in poj | Comments Off on Poj Solution 1844

Poj Solution 1840

http://poj.org/problem?id=1840 //* @author: import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int a1=sc.nextInt(); int a2=sc.nextInt(); int a3=sc.nextInt(); int a4=sc.nextInt(); int a5=sc.nextInt(); System.out.println( hashQuestions(a1,a2, a3,a4,a5)); } /** * @param a1 * @param a2 * @param … Continue reading

Posted in poj | Comments Off on Poj Solution 1840

Poj Solution 1837

http://poj.org/problem?id=1837 //PKU_1837_Balance_DP(û˼·) #include <iostream> #include <cstring> using namespace std; int C,G; int Pos[22]; int Weight[22]; int Value[22][7505];//������ȫΪ��25���������һͷ�����ʮ��Ϊ25*10*15(�۳�) = 3750 //Ȼ���״̬ƽ��ȫΪ��Ϊ7500��״̬��ȡ7505 int main() { while(cin>>C>>G) { for(int i = 1;i <= C;i++) cin>>Pos[i]; for(int i = 1;i <= G;i++) cin>>Weight[i]; memset(Value,0,sizeof(Value)); … Continue reading

Posted in poj | Comments Off on Poj Solution 1837

Poj Solution 1836

http://poj.org/problem?id=1836 //* @author: import java.util.Scanner; public class Main{ private int n; private double a[]; int b[],c[],sum[]; public Main(int n,double a[]){ this.n=n; this.a=a; b=new int[n+1]; c=new int[n+1]; sum=new int[n+1]; } public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); double … Continue reading

Posted in poj | Comments Off on Poj Solution 1836

Poj Solution 1835

http://poj.org/problem?id=1835 //* @author popop0p0popo import java.util.*; import java.io.*; public class Main{ public static int x,y,z,p,h; public static void main(String[] args){ Scanner scanner=new Scanner(new BufferedReader(new InputStreamReader(System.in))); int n=scanner.nextInt(); int m,s; String f; for (int i=0;i< n ;i++ ){ m=scanner.nextInt(); x=y=z=p=0; h=2; … Continue reading

Posted in poj | Comments Off on Poj Solution 1835

Poj Solution 1833

http://poj.org/problem?id=1833 //* @author: 82638882@163.com import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); int a=Integer.parseInt(in.readLine()); while((a–)!=0) { String[] ss=in.readLine().split(" "); int l=Integer.parseInt(ss[0]); int cnt=Integer.parseInt(ss[1]); int[] arr=new int[l]; … Continue reading

Posted in poj | Comments Off on Poj Solution 1833

Poj Solution 1832

http://poj.org/problem?id=1832 import java.math.*; import java.util.*; public class Main { static BigInteger[] base = new BigInteger[128]; static void init(){ base[0] = BigInteger.ONE; for (int i=1; i< 128; i++){ base[i] = base[i-1].multiply(BigInteger.valueOf(2)); } } public static void main(String args[]){ init(); Scanner cin … Continue reading

Posted in poj | Comments Off on Poj Solution 1832