Codeforces Round #291 (Div. 2)

    今天开始CF - ABC 计划,开始慢慢补 之前的题目,不过C D E 能不能搞定我也不知道,看情况吧、、、

    链接:http://codeforces.com/contest/514


A. Chewbaсca and Number

Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digitt means replacing it with digit 9 - t.

Help Chewbacca to transform the initial number x to the minimum possiblepositive number by inverting some (possibly, zero) digits. The decimal representation of the final number shouldn't start with a zero.

Input

The first line contains a single integer x(1 ≤ x ≤ 1018) — the number that Luke Skywalker gave to Chewbacca.

Output

Print the minimum possible positive number that Chewbacca can obtain after inverting some digits. The number shouldn't contain leading zeroes.

Sample test(s)
Input
27
Output
22
Input
4545
Output
4444

    输入一个字符串,判断每一位数 t 经过9 - t 之后,看能否是数字变小,而且不能含前导 0 。

   

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

char s[20];

int main()
{
    while(~scanf("%s",s))
    {
        int len = strlen(s);
        if(s[0] - '0' >= 5 && (s[0] - '0' != 9))
            printf("%d",9 - (s[0] - '0'));
        else
            printf("%d",s[0]-'0');
        for(int i = 1; i < len; i ++)
        {
            if(s[i] - '0' >= 5)
                printf("%d",9 - (s[i] - '0'));
            else
                printf("%d",s[i]-'0');
        }
        printf("\n");
    }
}

   

B. Han Solo and Lazer Gun

There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates(x, y) on this plane.

Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point(x0, y0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point(x0, y0).

Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers.

The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location.

Input

The first line contains three integers n,x0 и y0 (1 ≤ n ≤ 1000, - 104 ≤ x0, y0 ≤ 104) — the number of stormtroopers on the battle field and the coordinates of your gun.

Next n lines contain two integers each xi, yi ( - 104 ≤ xi, yi ≤ 104) — the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point.

Output

Print a single integer — the minimum number of shots Han Solo needs to destroy all the stormtroopers.

Sample test(s)
Input
4 0 0
1 1
2 2
2 0
-1 -1
Output
2
Input
2 1 2
1 1
1 0
Output
1
Note

Explanation to the first and second samples from the statement, respectively:


    需要多少条经过指定点的线,才能使所有的点都被覆盖、、

    需要注意 精度的问题,一开始 我用的double 结果搞到 abs(point[i].k- point[j].k)  0.00000001 还是不行,其实这里有一个更好的解法就是

    (point[i].x-x)*(point[j].y- y)== (point[j].x- x)*(point[i].y- y), 这样可以解决精度问题。

    我用flag 表示是否是和指定的点在同一条垂直x 轴的直线上

    这里给出第24 组数据,输出答案为 2

    2 -10000 -10000
    9998 9999
    9999 10000

    代码如下(可能会有没用的代码)


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

#define N 1010

struct node
{
    int x, y;
    bool vis;
}point[N];

int main()
{
    int n, x, y;
    while(~scanf("%d%d%d",&n, &x, &y))
    {
        for(int i = 1; i <= n; i ++)
        {
            scanf("%d%d",&point[i].x, &point[i].y);
            point[i].vis = false;
        }
        int cnt = 0;
        bool flag = false;
        for(int i = 1;i <= n; i ++)
        {
            if(point[i].x == x)
            {
                point[i].vis = true;
                flag = true;
                continue;
            }
            if(!point[i].vis)
            {
                point[i].vis = true;
                for(int j = 1; j <= n; j ++)
                {
                    if(point[j].vis)
                        continue;
                    if(point[j].x == x)
                    {
                        point[j].vis = true;
                        flag = true;
                    }
                    else if((point[i].x -x)*(point[j].y - y) == (point[j].x - x)*(point[i].y - y))
                    {
                        point[j].vis = true;
                       // printf("%d -----------\n", j);
                    }
                }
                cnt ++;
                //printf("%d --- %d\n",i, cnt);
            }
        }
        if(flag)
           cnt ++;
        printf("%d\n", cnt);
    }
}


   

内容概要:本文档详细介绍了Analog Devices公司生产的AD8436真均方根-直流(RMS-to-DC)转换器的技术细节及其应用场景。AD8436由三个独立模块构成:轨到轨FET输入放大器、高动态范围均方根计算内核和精密轨到轨输出放大器。该器件不仅体积小巧、功耗低,而且具有广泛的输入电压范围和快速响应特性。文档涵盖了AD8436的工作原理、配置选项、外部组件选择(如电容)、增益调节、单电源供电、电流互感器配置、接地故障检测、三相电源监测等方面的内容。此外,还特别强调了PCB设计注意事项和误差源分析,旨在帮助工程师更好地理解和应用这款高性能的RMS-DC转换器。 适合人群:从事模拟电路设计的专业工程师和技术人员,尤其是那些需要精确测量交流电信号均方根值的应用开发者。 使用场景及目标:①用于工业自动化、医疗设备、电力监控等领域,实现对交流电压或电流的精准测量;②适用于手持式数字万用表及其他便携式仪器仪表,提供高效的单电源解决方案;③在电流互感器配置中,用于检测微小的电流变化,保障电气安全;④应用于三相电力系统监控,优化建立时间和转换精度。 其他说明:为了确保最佳性能,文档推荐使用高质量的电容器件,并给出了详细的PCB布局指导。同时提醒用户关注电介质吸收和泄漏电流等因素对测量准确性的影响。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值