Link:http://acm.fzu.edu.cn/problem.php?pid=2146
Problem:
Accept: 532 Submit: 728
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Fat brother and Maze are playing a kind of special (hentai) game on a string S. Now they would like to count the length of this string. But as both Fat brother and Maze are programmers, they can recognize only two numbers 0 and 1. So instead of judging the length of this string, they decide to judge weather this number is even.
Input
The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each case contains a line describe the string S in the treasure map. Not that S only contains lower case letters.
1 <= T <= 100, the length of the string is less than 10086
Output
For each case, output the case number first, and then output “Odd” if the length of S is odd, otherwise just output “Even”.
Sample Input
Sample Output
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
string s;
int cas,T;
while(cin>>T)
{
for(cas=1;cas<=T;cas++)
{
cin>>s;
if(s.length()%2==0)
cout<<"Case "<<cas<<": Even"<<endl;
else
cout<<"Case "<<cas<<": Odd"<<endl;
}
}
return 0;
}
Link:http://acm.fzu.edu.cn/problem.php?pid=2147
Problem:
Accept: 650 Submit: 1563
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Fat brother and Maze are playing a kind of special (hentai) game by two integers A and B. First Fat brother write an integer A on a white paper and then Maze start to change this integer. Every time Maze can select an integer x between 1 and A-1 then change A into A-(A%x). The game ends when this integer is less than or equals to B. Here is the problem, at least how many times Maze needs to perform to end this special (hentai) game.
Input
The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each case contains two integers A and B described above.
1 <= T <=100, 2 <= B < A < 100861008610086
Output
For each case, output the case number first, and then output an integer describes the number of times Maze needs to perform. See the sample input and output for more details.
Sample Input
Sample Output
import java.text.*;
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String args[])
{
Scanner cin=new Scanner(System.in);
BigInteger a,b,cnt,x;
int cas,T;
while(cin.hasNext())
{
T=cin.nextInt();
for(cas=1;cas<=T;cas++)
{
a=cin.nextBigInteger();
b=cin.nextBigInteger();
cnt=BigInteger.ZERO;
while(a.compareTo(b)>0)
{
x=a.add(BigInteger.ONE).divide(BigInteger.valueOf(2)).subtract(BigInteger.ONE);
a=a.subtract(x);
cnt=cnt.add(BigInteger.ONE);
}
System.out.println("Case "+cas+": "+cnt);
}
}
}
}
Link:http://acm.fzu.edu.cn/problem.php?pid=2151
Problem:
Accept: 569 Submit: 874
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, there are N*M coins in this board with two symbol “O” or “X”. Then they take turns to choose a grid with symbol “O” and change it into “X”. The game ends when all the symbols in the board are “X”, and the one who cannot play in his (her) turns loses the game. Fat brother and Maze like this kind of OOXX game very much and play it day and night. They don’t even need a little rest after each game!
Here's the problem: Who will win the game if both use the best strategy? You can assume that Maze always goes first.
Input
The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each case contains two integers N and M indicate the size of the board. Then goes N line, each line with M character shows the state of the board.
1 <= T <=100, 1 <= n <=100, 1 <= m <=100
Output
For each case, output the case number first, and then output the winner’s name, either Fat brother or Maze. See the sample input and output for more details.
Sample Input
Sample Output
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
char b[111][111];
int n,m;
int main()
{
int cnt,i,j,T,cas;
while(~scanf("%d",&T))
{
for(cas=1;cas<=T;cas++)
{
scanf("%d%d",&n,&m);
cnt=0;
for(i=0;i<n;i++)
{
scanf("%s",b[i]);
for(j=0;j<m;j++)
{
if(b[i][j]=='O')
cnt++;
}
}
if(cnt%2==1)
printf("Case %d: Maze\n",cas);
else
printf("Case %d: Fat brother\n",cas);
}
}
return 0;
}
Link:http://acm.fzu.edu.cn/problem.php?pid=2150
Problem:
Accept: 452 Submit: 1793
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid of this board is consisting of grass or just empty and then they start to fire all the grass. Firstly they choose two grids which are consisting of grass and set fire. As we all know, the fire can spread among the grass. If the grid (x, y) is firing at time t, the grid which is adjacent to this grid will fire at time t+1 which refers to the grid (x+1, y), (x-1, y), (x, y+1), (x, y-1). This process ends when no new grid get fire. If then all the grid which are consisting of grass is get fired, Fat brother and Maze will stand in the middle of the grid and playing a MORE special (hentai) game. (Maybe it’s the OOXX game which decrypted in the last problem, who knows.)
You can assume that the grass in the board would never burn out and the empty grid would never get fire.
Note that the two grids they choose can be the same.
Input
The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each case contains two integers N and M indicate the size of the board. Then goes N line, each line with M character shows the board. “#” Indicates the grass. You can assume that there is at least one grid which is consisting of grass in the board.
1 <= T <=100, 1 <= n <=10, 1 <= m <=10
Output
For each case, output the case number first, if they can play the MORE special (hentai) game (fire all the grass), output the minimal time they need to wait after they set fire, otherwise just output -1. See the sample input and output for more details.
Sample Input
Sample Output
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
using namespace std;
struct node{
int r;
int c;
int t;
}st1,st2,mapp[111];
int d[4][2]={{0,1},{1,0},{-1,0},{0,-1}},vis[11][11];
int n,m,ans,maxt,cnt,cnt1;
char map[11][11];
bool cango(int r,int c)
{
if(r>=0&&r<n&&c>=0&&c<m)
return true;
return false;
}
void dfs(int r,int c)
{
int ri,ci;
vis[r][c]=1;
for(int i=0;i<4;i++)
{
ri=r+d[i][0];
ci=c+d[i][1];
if(cango(ri,ci)&&!vis[ri][ci]&&map[ri][ci]=='#')
{
dfs(ri,ci);
}
}
}
int bfs(int r1,int c1,int r2,int c2)
{
maxt=0;
queue<node>Q;
memset(vis,0,sizeof(vis));
st1.r=r1;
st2.r=r2;
st1.c=c1;
st2.c=c2;
st1.t=0;
st2.t=0;
vis[r1][c1]=1;
vis[r2][c2]=1;
Q.push(st1);
Q.push(st2);
node now,next;
while(!Q.empty())
{
now=Q.front();
Q.pop();
for(int i=0;i<4;i++)
{
next.r=now.r+d[i][0];
next.c=now.c+d[i][1];
if(cango(next.r,next.c)&&!vis[next.r][next.c]&&map[next.r][next.c]=='#')
{
vis[next.r][next.c]=1;
next.t=now.t+1;
Q.push(next);
}
}
maxt=max(maxt,now.t);
}
return maxt;
}
int main()
{
int T,cas,i,j,k,tem,fg,l;
while(scanf("%d",&T)==1)
{
cas=0;
while(T--)
{
cas++;
scanf("%d%d",&n,&m);
cnt=0;
for(i=0;i<n;i++)
{
scanf("%s",map[i]);
for(j=0;j<m;j++)
{
if(map[i][j]=='#')
{
cnt++;
mapp[cnt].r=i;
mapp[cnt].c=j;
}
}
}
cnt1=0;
memset(vis,0,sizeof(vis));
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(!vis[i][j]&&map[i][j]=='#')
{
dfs(i,j);
cnt1++;
}
}
}
//printf("%d\n",cnt1);
if(cnt1>=3)
{
ans=-1;
}
else
{
//printf("%d",cnt);
ans=999999;
for(i=1;i<=cnt;i++)
{
for(j=i;j<=cnt;j++)
{
st1=mapp[i];
st2=mapp[j];
tem=bfs(st1.r,st1.c,st2.r,st2.c);
//.printf("%d\n",tem);
fg=1;
for(k=0;k<n;k++)
{
for(l=0;l<m;l++)
{
if(!vis[k][l]&&map[k][l]=='#')
{
fg=0;
break;
}
}
if(!fg)
break;
}
if(fg)
ans=min(tem,ans);
}
}
}
printf("Case %d: %d\n",cas,ans);
}
}
}
Link:http://acm.fzu.edu.cn/problem.php?pid=2148
Problem:
Accept: 434 Submit: 1223
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Fat brother and Maze are playing a kind of special (hentai) game in the clearly blue sky which we can just consider as a kind of two-dimensional plane. Then Fat brother starts to draw N starts in the sky which we can just consider each as a point. After he draws these stars, he starts to sing the famous song “The Moon Represents My Heart” to Maze.
You ask me how deeply I love you,
How much I love you?
My heart is true,
My love is true,
The moon represents my heart.
…
But as Fat brother is a little bit stay-adorable(呆萌), he just consider that the moon is a special kind of convex quadrilateral and starts to count the number of different convex quadrilateral in the sky. As this number is quiet large, he asks for your help.
Input
The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each case contains an integer N describe the number of the points.
Then N lines follow, Each line contains two integers describe the coordinate of the point, you can assume that no two points lie in a same coordinate and no three points lie in a same line. The coordinate of the point is in the range[-10086,10086].
1 <= T <=100, 1 <= N <= 30
Output
For each case, output the case number first, and then output the number of different convex quadrilateral in the sky. Two convex quadrilaterals are considered different if they lie in the different position in the sky.
Sample Input
Sample Output
判断是不是凹四边形。
如果四边形有一个点在另外三个点组成的三角形内部,这个四边形就是凹四边形,否则就是凸四边形。
凹四边形内部那个点和其余任意两点可以组成三个三角形,这三个三角形面积的和恰好为外部三个点组成的三角形面积。
这题目很简单:给多个不重复坐标点,求不重复的凸四边形个数。而且n最大是30,所以枚举所有四个点的组合。而判断是否构成凸四边的条件是:1:四点组合中要存在两条交叉的直线 2:四点组合中不能存在 “一个点在其他三个点组成的三角形 内部"(本代码选择的方案)。
代码