Meta
-
Recent Posts
Recent Comments
Archives
- May 2024
- April 2023
- February 2023
- January 2023
- December 2022
- November 2022
- September 2022
- June 2022
- July 2021
- January 2021
- February 2020
- September 2019
- March 2018
- February 2018
- August 2016
- July 2016
- June 2016
- May 2016
- April 2016
- March 2016
- February 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- August 2015
- July 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- April 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- September 2013
- August 2013
- July 2013
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
Categories
Category Archives: poj
Poj Solution 3984
http://poj.org/problem?id=3984 #include <iostream> using namespace std; const int M=2147483647; int b[5][5]; void calc(int a[][5],int i,int j); void print(int i,int j); int main() { int i,j; int a[5][5]; for(i=0;i<=4;i++) for(j=0;j<=4;j++) { cin>>a[i][j]; if(a[i][j]==1) a[i][j]=M; } calc(a,0,0); print(4,4); return 0; } void … Continue reading
Posted in poj
Leave a comment
Poj Solution 3983
http://poj.org/problem?id=3983 #include<stdio.h> int main(){ printf("5*(5-(1/5))n"); return 0; }
Posted in poj
Leave a comment
Poj Solution 3982
http://poj.org/problem?id=3982 #include <stdio.h> #include <string.h> #include <stdlib.h> #define MAX_LEN 1024 void BigIntegerAdd(const char a[], const char b[], char res[]) { int i, j, k; int x, y, z; int up, l; char *c; if(strlen(a) > strlen(b)) { l = strlen(a) … Continue reading
Posted in poj
Leave a comment
Poj Solution 3981
http://poj.org/problem?id=3981 #include <stdio.h> #include <string.h> #define MAX_LEN 1024 int main(int argc, char **argv) { char str[MAX_LEN]; int i, len; while(gets(str)) { len = strlen(str); for(i = 0; i < len; ++i) { if(‘y’ != str[i]) { putchar(str[i]); } else { … Continue reading
Posted in poj
Leave a comment
Poj Solution 3980
http://poj.org/problem?id=3980 #include <stdio.h> int mod(int n, int m){ return n%m; } int main(){ int m,n; while(scanf("%d%d",&n,&m)!=EOF){ printf("%dn",mod(n,m)); } return 0; }
Posted in poj
Leave a comment
Poj Solution 3979
http://poj.org/problem?id=3979 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> int gdb(int a,int b) { int tmp,ret; if(a < b) { tmp = a; a = b; b =tmp; } while(b) { tmp = a; a = b; b = tmp%b; … Continue reading
Posted in poj
Leave a comment
Poj Solution 3934
http://poj.org/problem?id=3934 #include <stdio.h> int dp[81][201]; int main() { int n,m,i,j,k; for(i=1;i<=80;i++){ for(j=0,k=i-1;j<k;j++) dp[i][j]=0; } dp[1][0]=1; dp[2][1]=2; dp[3][2]=4; dp[3][3]=2; for(i=4;i<=80;i++){ for(j=i-1;j<=200;j++){ dp[i][j]=0; if(j>=2) dp[i][j]=(dp[i-1][j-2]*(i-2))%9937; if(j>=1) dp[i][j]=(dp[i][j]+dp[i-1][j-1]*2)%9937; } } while(scanf("%d%d",&n,&m),n||m){ if(m>=200) printf("0n"); else printf("%dn",dp[n][m]); } return 0; }
Posted in poj
Leave a comment
Poj Solution 3768
http://poj.org/problem?id=3768 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { int n = sc.nextInt(); if (n == 0) break; sc.nextLine(); String[] template = new String[n]; for (int i = … Continue reading
Posted in poj
Leave a comment
Poj Solution 3767
http://poj.org/problem?id=3767 import java.util.Scanner; public class Main{ public static void dijkstra(int[][] GA, int[] leader, int road) { if (road == 0) System.out.println(-1); else { int size = GA.length; // System.out.println(size); int[] dist = new int[size]; int[] isUsed = new int[size]; isUsed[1] … Continue reading
Posted in poj
Leave a comment
Poj Solution 3763
http://poj.org/problem?id=3763 //* @author import java.util.*; import java.io.*; public class Main { static Scanner in = new Scanner(System.in); static class Node extends LinkedList< Node> { final int[] dp = new int[]{-1, -1}; int query(int b) { if(dp[b]< 0) init(null); return dp[b]; … Continue reading
Posted in poj
Leave a comment
Poj Solution 3753
http://poj.org/problem?id=3753 import java.io.BufferedInputStream; import java.util.Scanner; /** * *poj3753 * C������� * while(EOF != scanf("%s",source)) *�ȼ���java���while (scan.hasNext()) * @author NC */ public class Main { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); while (scan.hasNext()) { String … Continue reading
Posted in poj
Leave a comment
Poj Solution 3752
http://poj.org/problem?id=3752 import java.io.BufferedInputStream; import java.util.Scanner; /** * *poj3752 * ģ�� * @author NC */ public class Main { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); if (scan.hasNext()) { int m = scan.nextInt(); int n = … Continue reading
Posted in poj
Leave a comment
Poj Solution 3751
http://poj.org/problem?id=3751 import java.io.BufferedInputStream; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * poj3751 easy * … Continue reading
Posted in poj
Leave a comment
Poj Solution 3750
http://poj.org/problem?id=3750 #include <stdio.h> #include <string.h> int main() { int n, w, s; int i, j; char name[65][16]; scanf("%d", &n); getchar(); for (i=0; i<n; ++i) { gets(name[i]); } scanf("%d,%d", &w, &s); i = w-1; while (n != 0) { if (i+s-1 … Continue reading
Posted in poj
Leave a comment
Poj Solution 3749
http://poj.org/problem?id=3749 #include<stdio.h> #include<string.h> int main() { void translate(char word[]); char start[20]; char end[20]; char word[205]; while(1) { gets(start); if(strcmp(start,"START")!=0) break; gets(word); translate(word); puts(word); gets(end); } } void translate(char word[]) { int i,len; len=strlen(word); for(i=0;i<len;i++) { if(word[i]>=’A’&&word[i]<=’E’) { word[i]+=21; } else … Continue reading
Posted in poj
Leave a comment
Poj Solution 3748
http://poj.org/problem?id=3748 import java.io.BufferedInputStream; import java.util.Scanner; /** * *poj3748 * λ���� * @author NC */ public class Main { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); if (scan.hasNext()) { String[] ss = scan.nextLine().trim().split("[,]"); Integer r = … Continue reading
Posted in poj
Leave a comment
Poj Solution 3747
http://poj.org/problem?id=3747 //* @author /** * @version 2009/08/31 * @author sbzlyessit */ import java.io.*; import java.util.*; public class Main { private static BufferedReader in =new BufferedReader(new InputStreamReader(System.in)); private static StringTokenizer st; private static double[] x = new double[10], y = new … Continue reading
Posted in poj
Leave a comment
Poj Solution 3744
http://poj.org/problem?id=3744 //* @author: <strong> import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); double p,p1,p2,p3; while (sc.hasNext()) { int n=sc.nextInt(); int a[]=new int[n+1]; p=sc.nextDouble(); for (int i=1;i<=n;i++) a[i]=sc.nextInt(); if (a[1]==1) {System.out.println("0.0000000");continue;} int now=1; p1=0;p2=1; for (int … Continue reading
Posted in poj
Leave a comment
Poj Solution 3742
http://poj.org/problem?id=3742 import java.math.BigInteger; import java.io.*; import java.util.*; public class Main { static int n; static BigInteger t=new BigInteger("1"); static BigInteger c[][] = new BigInteger [210][210]; /* static BigInteger C(int n,int m) { if(m==0||m==n) return BigInteger.ONE; BigInteger res=new BigInteger("1"); int i; … Continue reading
Posted in poj
Leave a comment
Poj Solution 3740
http://poj.org/problem?id=3740 //* @author /** * @version 2009/08/28 * @author sbzlyessit */ import java.io.*; import java.util.*; public class Main { private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private static StringTokenizer st; private static int[] matrix = new int[300]; public static … Continue reading
Posted in poj
Leave a comment
Poj Solution 3737
http://poj.org/problem?id=3737 //* @author: <strong> import java.util.*; public class Main{ static final double pi=Math.PI; public static void main(String args[]){ Scanner sc=new Scanner(System.in); double s; while (sc.hasNext()) { s=sc.nextDouble(); double h=Math.sqrt(2*s/pi); double r=Math.sqrt(s*s/(pi*pi*h*h+2*pi*s)); double v=(1.0/3.0)*(s*s)*h/(pi*h*h+2*s); System.out.printf("%.2fn%.2fn%.2fn",v,h,r); } } }
Posted in poj
Leave a comment
Poj Solution 3736
http://poj.org/problem?id=3736 //* @author: import java.io.*; import java.math.*; import java.util.*; import java.util.Comparator; import java.util.ArrayList; public class Main { public static class node { double x,y,s,r,d,t; node(double xx,double yy,double ss,double rr,double dd,double tt) { x=xx;y=yy;s=ss;r=rr;d=dd;t=tt; } double getx(){return x;} double gety(){return y;} … Continue reading
Posted in poj
Leave a comment
Poj Solution 3734
http://poj.org/problem?id=3734 //* @author: ccQ.SuperSupper import java.io.*; import java.util.*; public class Main { /** * @param args * @return */ static int pow_mod(int a,int b,int c) { int r=1,d=a; while(b>0){ if((b&1)==1) r = r*d%c; d = d*d%c; b>>=1; } return r; … Continue reading
Posted in poj
Leave a comment
Poj Solution 3723
http://poj.org/problem?id=3723 //* @author: //Kruskal �㷨: import java.io.*; import java.util.*; class cin { static int leave=0; static StringTokenizer st; static BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); static int nextInt() throws Exception { while (leave==0) { st=new StringTokenizer(in.readLine()); leave=st.countTokens(); } leave–; return Integer.parseInt(st.nextToken()); } … Continue reading
Posted in poj
Leave a comment
Poj Solution 3720
http://poj.org/problem?id=3720 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; /** * @author Administrator ѭ��С��+ѭ���� */ public class Main { /** *���� */ private int numerator; /** *��ĸ */ private int denominator; /** * ѭ���ڲ��ᳬ��100����� */ private static int … Continue reading
Posted in poj
Leave a comment
Poj Solution 3708
http://poj.org/problem?id=3708 import java.util.*; import java.math.*; public class Main { static BigInteger x,y; static BigInteger[] a=new BigInteger[1000]; static BigInteger[] m=new BigInteger[1000]; static void egcd(BigInteger a,BigInteger b){ if(b.equals(BigInteger.ZERO)){ x=BigInteger.ONE; y=BigInteger.ZERO; return ; } egcd(b,a.mod(b)); BigInteger temp=y; y=x.subtract((a.divide(b)).multiply(y)); x=temp; } static BigInteger solve(int … Continue reading
Posted in poj
Leave a comment
Poj Solution 3705
http://poj.org/problem?id=3705 //* @author: import java.util.Scanner; public class Main { Scanner cin = new Scanner(System.in); int n; public void inPut() { n = cin.nextInt(); reverse(); } private void reverse() { if (n == 1) { System.out.println(0); } else { if (n … Continue reading
Posted in poj
Leave a comment
Poj Solution 3692
http://poj.org/problem?id=3692 //* @author: <strong>Yeming Hu</strong>"cslittleye@gmail.com" import java.util.*; public class Main { public static int b; public static int g; public static int m; public static boolean[][] graph; public static boolean[] checked; public static int[] link; public static void main(String[] args) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 3687
http://poj.org/problem?id=3687 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ int degree[]=new int[210]; boolean visit[][]=new boolean[210][210]; int path[]=new int[210]; int n,m,t; void topsort(){ for(int k=n;k>=1;k–){ int i=n; while(i>=1 && degree[i]!=0) i–; if(i< 1){ System.out.printf("-1n"); return; } degree[i]=-1; path[i]=k; for(int … Continue reading
Posted in poj
Leave a comment
Poj Solution 3677
http://poj.org/problem?id=3677 //* @author import java.util.*; import java.io.*; class Main { static int armor[]; final static int MAX = 1000000; static class Node { Node l = null, r = null; int flag, step, value; Node(int k, int v) { flag … Continue reading
Posted in poj
Leave a comment
Poj Solution 3673
http://poj.org/problem?id=3673 import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scanner=new Scanner(System.in); String str1=scanner.next(); String str2=scanner.next(); char[] array1=str1.toCharArray(); char[] array2=str2.toCharArray(); int sum1=0; for(int i=0;i< array1.length;i++){ sum1+=array1[i]-48; } int sum2=0; for(int i=0;i< array2.length;i++){ sum2+=array2[i]-48; } System.out.println(""+(sum1*sum2)); } }
Posted in poj
Leave a comment
Poj Solution 3672
http://poj.org/problem?id=3672 //* @author ������<hongxp11@163.com> import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int M = in.nextInt(); int T = in.nextInt(); int … Continue reading
Posted in poj
Leave a comment
Poj Solution 3671
http://poj.org/problem?id=3671 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; int v[]=new int[30002]; int f[]=new int[30002]; int g[]=new int[30002]; n=sc.nextInt(); for(int i=1;i<=n;i++) v[i]=sc.nextInt(); f[0]=0; g[n+1]=0; for(int i=1;i<=n;i++){ if(v[i]==2) f[i]=f[i-1]+1; else f[i]=f[i-1]; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 3670
http://poj.org/problem?id=3670 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ static int mintwo(int a,int b){ return a< b?a:b; } static int minthird(int a,int b,int c){ int temp=mintwo(a,b); return mintwo(temp,c); } public static void main(String args[]){ Scanner sc=new Scanner(System.in); int … Continue reading
Posted in poj
Leave a comment
Poj Solution 3665
http://poj.org/problem?id=3665 /* @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 arr[]=new int[10010]; int n,m,i,j,u; n=sc.nextInt(); m=sc.nextInt(); for(i=0;i< n;i++) arr[i]=sc.nextInt(); for(i=0;i< m;i++) { int maxx=-1,tag=0; for(j=0;j< n;j++) if(arr[j]>maxx) { maxx=arr[j]; … Continue reading
Posted in poj
Leave a comment
Poj Solution 3664
http://poj.org/problem?id=3664 //* @author ������<hongxp11@163.com> import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Scanner; public class Main { static class vote { int first; int second; int index; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int N … Continue reading
Posted in poj
Leave a comment
Poj Solution 3663
http://poj.org/problem?id=3663 //* @author: 82638882@163.com import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int a=in.nextInt(); int b=in.nextInt(); ArrayList< Integer> arr=new ArrayList< Integer>(); for(int i=0;i< a;i++) arr.add(in.nextInt()); Collections.sort(arr); int count=0; for(int i=0;i< a-1;i++) { int … Continue reading
Posted in poj
Leave a comment
Poj Solution 3660
http://poj.org/problem?id=3660 //* @author popop0p0popo import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ Scanner in=new Scanner(new BufferedReader(new InputStreamReader(System.in))); int n=in.nextInt(); int m=in.nextInt(); int[][] p=new int[n][n]; for (int i=0;i< n ;i++ ){ for (int j=0;j< n ;j++ ){ … Continue reading
Posted in poj
Leave a comment
Poj Solution 3658
http://poj.org/problem?id=3658 //* @author /** * @version 2009/08/21 * @author sbzlyessit */ import java.io.*; import java.util.*; public class Main { private static final int MAX_N = 100000; private static BufferedReader in =new BufferedReader(new InputStreamReader(System.in)); private static StringTokenizer st; private static int[] … Continue reading
Posted in poj
Leave a comment
Poj Solution 3653
http://poj.org/problem?id=3653 //* @author: SmilingWang import java.util.*; import java.io.*; public class Main { static final int INF = 100000000; public static void main(String[] args){ Scanner in = new Scanner(new BufferedInputStream(System.in)); int x = in.nextInt(); int y = in.nextInt(); while(x != 0 … Continue reading
Posted in poj
Leave a comment
Poj Solution 3652
http://poj.org/problem?id=3652 import java.util.Arrays; import java.util.Scanner; public class Main { int a; int b; int c; int s; int x; char[] result; int flg; boolean[] dup; public Main() { Scanner scan = new Scanner(System.in); while ((a = scan.nextInt()) != 0) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 3650
http://poj.org/problem?id=3650 //* @author ������<hongxp11@163.com> import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(true) { String input = in.nextLine(); if(input.equals("#")) break; int len = input.length(); for(int i = 0; i < len; … Continue reading
Posted in poj
Leave a comment
Poj Solution 3646
http://poj.org/problem?id=3646 //* @author: import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i,j,ans; end: while (sc.hasNext()) { int n=sc.nextInt(); if(n==0) break; int m=sc.nextInt(); int a[]=new int[n+1]; int b[]=new int[m+1]; for ( i=1;i<=n;i++) a[i]=sc.nextInt(); for … Continue reading
Posted in poj
Leave a comment
Poj Solution 3641
http://poj.org/problem?id=3641 //* @author: 82638882@163.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); while(true) { long p=in.nextLong(); long a=in.nextLong(); if(a==0&&p==0) break; if(isPrime(p)){ System.out.println("no"); continue; } System.out.println(sum(a,p,p)==a?"yes":"no"); } } public static boolean isPrime(long a) { … Continue reading
Posted in poj
Leave a comment
Poj Solution 3640
http://poj.org/problem?id=3640 //* @author ������<hongxp11@163.com> import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; public class Main { /** * @param args * @throws IOException * @throws NumberFormatException */ public … Continue reading
Posted in poj
Leave a comment
Poj Solution 3639
http://poj.org/problem?id=3639 //* @author: import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i,n; double rate,us,ca,tus,tca,t1,t2; while (sc.hasNext()) { n=sc.nextInt(); if(n==0) break; ca=1000;us=0; for (i=1;i<=n;i++) { rate=sc.nextDouble(); t1=ca/rate*.97; t1=(Math.floor(t1*100))/100; t2=us*rate*.97; t2=(Math.floor(t2*100))/100; tus=(us>t1?us:t1); tca=(ca>t2?ca:t2); us=tus;ca=tca; } … Continue reading
Posted in poj
Leave a comment
Poj Solution 3637
http://poj.org/problem?id=3637 //* @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 n=scanner.nextInt(); int t,total; int[] prs; for (int i=0;i< n ;i++ ){ t=scanner.nextInt(); prs=new int[t]; for (int j=0;j< t … Continue reading
Posted in poj
Leave a comment
Poj Solution 3633
http://poj.org/problem?id=3633 //* @author /** * @version 2009/08/26 * @author sbzlyessit */ /*������. ״̬����, ���ü��仯����, ����ת�ƺķѾ�, ���������֦. *����Ҫ��һ���֦����ÿһλƥ��ʱ��Ҫȡ��ij��Ƚ�����һ������. */ import java.io.*; import java.util.*; public class Main { private static final int MAX_N = 18; private static BufferedReader in = new BufferedReader(new … Continue reading
Posted in poj
Leave a comment
Poj Solution 3632
http://poj.org/problem?id=3632 //* @author: 82638882@163.com import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int a=in.nextInt(); while(a!=0) { int b=in.nextInt(); int[] c=new int[b]; for(int i=0;i< b;i++) { c[i]=in.nextInt(); } int d,e,g; for(d=e=c[0],g=0;g< b;g++) { if(d>c[g])d=c[g]; … Continue reading
Posted in poj
Leave a comment