# Monthly Archives: August 2015

## Poj Solution 3217

http://poj.org/problem?id=3217 #include <stdio.h> #include <memory.h> #include <vector> using namespace std; vector<int> ch[101]; int father[101], mother[101]; bool gender[101]; int A, B; void input( ) { int i, h, t; scanf( "%d%d", &A, &B ); for( i=0; i<101; i++ ) ch[i].clear( ); … Continue reading

## Poj Solution 3214

http://poj.org/problem?id=3214 #include <stdio.h> #include <memory.h> #include <vector> #include <algorithm> using namespace std; vector<int> v[20]; int a[2100000]; int t[2100000]; int n, m, h; int vn[20]; void input( ) { int i, j; scanf( "%d", &m ); for( i=0; i<m; i++ ) … Continue reading

## Poj Solution 3212

http://poj.org/problem?id=3212 #include <stdio.h> #include <memory.h> #include <vector> #include <algorithm> using namespace std; #define __int64 long long const int size = 100010; __int64 s[size]; int ss[size]; int m; int pos[100100]; //��� void clear( ) { memset( s, 0, sizeof s ); … Continue reading

## Poj Solution 3211

http://poj.org/problem?id=3211 #include <stdio.h> #include <vector> #include <string> #include <set> using namespace std; vector<int> v[10]; string color[10]; set<int> s; int main( ) { int n, m, i, j, ans, sum, t, best; char w[100]; while( scanf( "%d%d", &m, &n ) == … Continue reading

## Poj Solution 3210

http://poj.org/problem?id=3210 //* @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; while (true){ n=scanner.nextInt(); if (n==0){ break; } if (n%2==0){ System.out.println("No Solution!"); } else{ System.out.println(n-1); } } } … Continue reading

## Poj Solution 3208

http://poj.org/problem?id=3208 /* @author: */ import java.util.Scanner; public class Main { static int s[][]=new int[14][4]; static int to[][]=new int[4][10]; static void doit( ) { int i, j, k; for( i=0; i< 3; i++ ) for( j=0; j< 10; j++ ) to[i][j] … Continue reading

## Poj Solution 3199

http://poj.org/problem?id=3199 import java.io.BufferedInputStream; import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); while (scan.hasNext()) { BigDecimal n = scan.nextBigDecimal(); int d = scan.nextInt(); if (d == 0 && n.equals(BigDecimal.ZERO)) … Continue reading

## Poj Solution 3198

http://poj.org/problem?id=3198 /* @author: */ import java.math.BigInteger; import java.util.*; public class Main { public static BigInteger get( BigInteger h ) { BigInteger s = h.shiftLeft(1); BigInteger a = BigInteger.ONE.shiftLeft( s.bitLength()/2-1 ).subtract( BigInteger.ONE ); BigInteger b = BigInteger.ONE.shiftLeft( s.bitLength()/2+1 ), c; while( … Continue reading

## Poj Solution 3194

http://poj.org/problem?id=3194 /* @author: */ import java.util.Scanner; import java.util.Arrays; public class Main{ static int p[][]=new int[105][105]; static int q[][]=new int[101][101]; static int n,cnt; static void dfs(int i,int j) { if(i>n||j>n||i< 1||j< 1) return; q[i][j]=cnt; if(q[i][j+1]==0&&p[i][j]==p[i][j+1]) dfs(i,j+1); if(q[i][j-1]==0&&p[i][j]==p[i][j-1]) dfs(i,j-1); if(q[i+1][j]==0&&p[i][j]==p[i+1][j]) dfs(i+1,j); if(q[i-1][j]==0&&p[i][j]==p[i-1][j]) … Continue reading

## Poj Solution 3193

http://poj.org/problem?id=3193 //* @author: <strong>Yeming&nbsp;Hu</strong>&quot;cslittleye@gmail.com&quot; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String mn = sc.nextLine(); Scanner lmn = new Scanner(mn); int m = lmn.nextInt(); int n = lmn.nextInt(); String[] phrases … Continue reading

## Poj Solution 3192

http://poj.org/problem?id=3192 #include <stdio.h> #include <algorithm> #include <string> #include <string.h> using namespace std; int index[7]; char sum[100]; char str[7][10]; int len[7]; int merge( int len, char *w, int l ) { int i = len-l, j; if( i<0 ) i = … Continue reading