NC206686. Dressaswomen
描述
输入描述
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"); } }