列表

详情


NC206686. Dressaswomen

描述

One day, zyh and fzj are playing a game called Bejeweled, and they have promised the loser would dress as women.

The rules are as follows, in a two-dimensional plane, each time one can remove one or multiple collinear points from the plane. The one who removes the last point on the plane will win the game.

They both want the other to dress as women, so they always make the best choice. Now fyt wants to know who will lose. Note that zyh will always take the first.

输入描述

The first line is an positive integer n  .

The following n lines each contains two integers x and y , describing the coordinates of each point.

输出描述

Print the name of the one who win the game `zyh` or `fzj` (without quotes).

示例1

输入:

3
0 0
114514 114514
2 2

输出:

zyh

示例2

输入:

3
0 0
1 1
2 3

输出:

fzj

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++11(clang++ 3.9) 解法, 执行用时: 3ms, 内存消耗: 488K, 提交时间: 2020-06-13 19:53:00

#include<stdio.h>
#define ll long long 
int n;
ll x[20],y[20];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&x[i],&y[i]);
	}
	int flag=0; 
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int k=j+1;k<=n;k++){
				if((y[j]-y[i])*(x[k]-x[i])==(y[k]-y[i])*(x[j]-x[i])){
					flag=1;
				}
			}
		}
	}
	if((n%3==0)&&(flag==0)){
		printf("fzj\n");
	}
	else{
		printf("zyh\n");
	}
}

C++14(g++5.4) 解法, 执行用时: 3ms, 内存消耗: 376K, 提交时间: 2020-06-13 16:29:50

#include<stdio.h>
#define ll long long 
int n;
ll x[20],y[20];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&x[i],&y[i]);
	}
	int flag=0; 
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int k=j+1;k<=n;k++){
				if((y[j]-y[i])*(x[k]-x[i])==(y[k]-y[i])*(x[j]-x[i])){
					flag=1;
				}
			}
		}
	}
	if((n%3==0)&&(flag==0)){
		printf("fzj\n");
	}
	else{
		printf("zyh\n");
	}
}

上一题