10167—Birthday Cake

题目的意思是,给你2*n个点,让你找出AX+BY=0这样一条直线,使得2*n个点分居在这条直线的两边。。。。。。。

由于所给数据是-500~500,则可以完全暴力。

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;

int A[1009],P[1009];

struct list
{
    int x;
    int y;
}point[100009];

int main()
{
    int n,i,a,b;
    while(scanf("%d",&n)==1)
    {
        if(n==0)
            break;
        for(i=0;i<2*n;i++)
            scanf("%d%d",&point[i].x,&point[i].y);
        int leap=1;
        for(a=-500;a<=500;a++)
        {
            for(b=-500;b<=500;b++)
            {
                int num=0;
                if(a==0&&b==0)
                    continue;
                for(i=0;i<2*n;i++)
                {
                    if((a*point[i].x+b*point[i].y)>0)
                        num++;
                    if(a*point[i].x+b*point[i].y==0)
                        break;
                }
                if(num==n&&i==2*n)//对列出的点都计算了,i==2*n;
                {
                    leap=0;
                    break;
                }
            }
            if(leap==0)
                break;
        }
        printf("%d %d\n",a,b);
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这是一个使用 HTML5 制作的带有动画效果的 "Happy Birthday" 的代码示例: ``` <!DOCTYPE html> <html> <head> <style> .cake { position: relative; width: 300px; height: 300px; margin: 50px auto; } .candle { position: absolute; width: 20px; height: 100px; background: orange; border-radius: 10px 10px 0 0; transform: translate(140px, -40px); animation: flicker 1s infinite; } .candle::before { content: ""; position: absolute; width: 20px; height: 20px; background: white; border-radius: 50%; top: -20px; } .candle::after { content: ""; position: absolute; width: 20px; height: 50px; background: white; border-radius: 10px 10px 0 0; top: -50px; } @keyframes flicker { 0% { transform: translate(140px, -40px) scaleY(1); } 50% { transform: translate(140px, -40px) scaleY(0.5); } 100% { transform: translate(140px, -40px) scaleY(1); } } .cake-layer { position: absolute; width: 300px; height: 300px; border-radius: 50%; background: pink; transform: translateY(100px); } .cake-layer:nth-child(2) { background: purple; transform: translateY(50px); } .cake-layer:nth-child(3) { background: yellow; transform: translateY(0px); } .cake-layer:nth-child(4) { background: orange; transform: translateY(-50px); } .cake-layer:nth-child(5) { background: red; transform: translateY(-100px); } .cake-layer:nth-child(6) { background: green; transform: translateY(-150px); } .cake-layer:nth-child(7) { background: blue; transform: translateY(-200px); } .cake-layer:nth-child(8) { background: purple; transform: translateY(-250px); } .cake-layer:nth-child(9) { background: pink; transform: translateY(-300px); } .frosting { position: absolute; width: 300px; height: 300px; border-radius: 50%; background: white; box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); transform: translateY(-350
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值