A.水题 数字翻转,将每一位大于等于5的数字t翻转成9-t,注意不要有前导0,且翻转后数字的位数不变(即9999->9000...刚开始以为应该翻转成0了= =)

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
char x[];
cin >> x;
int len = strlen(x);
for(int i = ; i < len; i++)
if(x[i] >= '') x[i] = '' - x[i] + '';
if(x[] == '') x[] = '';
cout << x << endl;
return ;
}
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
char x[];
cin >> x;
int len = strlen(x);
for(int i = ; i < len; i++)
if(x[i] >= '') x[i] = '' - x[i] + '';
if(x[] == '') x[] = '';
cout << x << endl;
return ;
}

B.水题 斜率,每输入一个坐标(xi,yi)求出该点与标准点连线的斜率并记入数组k[]中,排序(sort),去重(unique);

NOTE:斜率注意的基本问题---斜率为无穷大与0时的特判;

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = ;
int main()
{
int n, cnt1 = , cnt2 = ;
double x0, y0, x, y;
double k[maxn];
scanf("%d%lf%lf", &n, &x0, &y0);
for(int i = ; i < n; i++)
{
scanf("%lf%lf", &x, &y);
if(x-x0 == ) {cnt1++; k[i] = ; continue;}
if(y-y0 == ) {cnt2++; k[i] = ; continue;}
k[i] = (y-y0)/(x-x0);
}
sort(k, k+n);
int ans = unique(k, k+n) - k;
if(cnt1 && cnt2) ans++;
cout << ans << endl;
return ;
}

#291 div.2的更多相关文章

  1. hash+set Codeforces Round #291 (Div. 2) C. Watto and Mechanism

    题目传送门 /* hash+set:首先把各个字符串的哈希值保存在set容器里,然后对于查询的每一个字符串的每一位进行枚举 用set的find函数查找是否存在替换后的字符串,理解后并不难.另外,我想用 ...

  2. 暴力/set Codeforces Round #291 (Div. 2) C. Watto and Mechanism

    题目传送门 /* set的二分查找 如果数据规模小的话可以用O(n^2)的暴力想法 否则就只好一个一个的换(a, b, c),在set容器找相匹配的 */ #include <cstdio> ...

  3. 数学 Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun

    题目传送门 /* 水题,就是用三点共线的式子来判断射击次数 */ #include <cstdio> #include <cmath> #include <string& ...

  4. 贪心/字符串处理 Codeforces Round #291 (Div. 2) A. Chewbaсca and Number

    题目传送门 /* WA了好几次,除了第一次不知道string不用'\0'外 都是欠考虑造成的 */ #include <cstdio> #include <cmath> #in ...

  5. Codeforces Round #291 (Div. 2)

    A 题意:给出变换规则,单个数字t可以变成9-t,然后给出一个数,问最小能够变成多少. 自己做的时候理解成了不能输出前导0,但是题目的本意是不能有前导0(即最高位不能是0,其余位数按照规则就好) 55 ...

  6. Codeforces Round #291 (Div. 2) C - Watto and Mechanism 字符串

    [题意]给n个字符串组成的集合,然后有m个询问(0 ≤ n ≤ 3·105, 0 ≤ m ≤ 3·105) ,每个询问都给出一个字符串s,问集合中是否存在一个字符串t,使得s和t长度相同,并且仅有一个 ...

  7. Watto and Mechanism Codeforces Round #291 (Div. 2)

    C. Watto and Mechanism time limit per test 3 seconds memory limit per test 256 megabytes input stand ...

  8. Codeforces Round #291 (Div. 2) C. Watto and Mechanism [字典树]

    传送门 C. Watto and Mechanism time limit per test 3 seconds memory limit per test 256 megabytes input s ...

  9. Codeforces Round #291 (Div. 2) D. R2D2 and Droid Army [线段树+线性扫一遍]

    传送门 D. R2D2 and Droid Army time limit per test 2 seconds memory limit per test 256 megabytes input s ...

随机推荐

  1. activemq 的小实验

    package ch02.chat; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms ...

  2. bzoj 3123 [Sdoi2013]森林(主席树,lca,启发式合并)

    Description Input 第一行包含一个正整数testcase,表示当前测试数据的测试点编号.保证1≤testcase≤20. 第二行包含三个整数N,M,T,分别表示节点数.初始边数.操作数 ...

  3. 【bzoj1300】大数计算器

    题意: 求C(n,m) 如果C(n,m)的位数<=12 那么直接输出 否则按XXX...XXXXXXXXX的形式输出 题解: 这题之前打过 但是昨天又想出一种新的做法 先说下新的做法吧- - _ ...

  4. Windows性能监视器之CPU、硬盘、IO等监控方法详解-摘自网络

    一般操作系统性能主要涉及到的问题主要有:处理器使用情况.内存占有量.磁盘I/0操作以及网络流量等. 查看Windows性能情况,大部分情况下是通过 “Windows任务管理器”,可以通过在 ”命令行” ...

  5. adb不响应

    1.CMD命令窗口输入:adb nodaemon server .然后就会提示你哪个端口被占用了. 2.输入netstat -ano | findstr "5037" .然后会弹出 ...

  6. 【Android】JSONArray的合并

    在Android开发过程中,需要处理解析服务器JSON数据时,或需要进行两个或多个JSONArray合并操作. 比如在进行LIstView的动态更新时. 在此提供一种JSONArray合并的方法,方便 ...

  7. git安装教程

    msysgit是Windows版的Git,从https://git-for-windows.github.io下载(网速慢的同学请移步国内镜像),然后按默认选项安装即可. 安装完成后,在开始菜单里找到 ...

  8. [置顶] [BZOJ]2127: happiness 最小割

    happiness: Description 高一一班的座位表是个n*m的矩阵,经过一个学期的相处,每个同学和前后左右相邻的同学互相成为了好朋友.这学期要分文理科了,每个同学对于选择文科与理科有着自己 ...

  9. R 语言画图的基本参数

    R 语言画图的基本参数 点 点的种类 点的种类参数为 pch,每一种符号对应一个数字编号 # 点有25种,为了展示25种点 x = 1:25 y = 1:25 x ## [1] 1 2 3 4 5 6 ...

  10. Sql sp_executesql 参数问题

    DECLARE @name NVARCHAR(30), @sql NVARCHAR(300)set @sql= N'SELECT TOP 1 @n=EmpName from dbo.Emp' exec ...