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. Android UI -- 布局介绍(布局包括FrameLayout, LinearLayout, RelativeLayout, GridLayout)

    首先介绍常用布局类 FrameLayout 最简单的布局管理器. 这个布局管理类有几个特性: 添加组件默认在左上角的. 如果添加多个组件会叠加到一起,并且都在左上角.(可以通过一gravity属性改变 ...

  2. [GRYZ2015]足球联赛

    问题描述 巴蜀中学新一季的足球联赛开幕了.足球联赛有n 只球队参赛,每赛季,每只球队要与其他球队各赛两场,主客各一场,赢一场得3 分,输一场不得分,平局两只队伍各得一分.英勇无畏的小鸿是机房的主力前锋 ...

  3. MFC文档、视图和框架

    文档.视图.框架 文档/视图结构是MFC提供的一种不错的设计,它将数据的处理和显示分开来,这样更便于我们对程序的维护和扩展. 文档        文档对象用于管理和维护数据,包括保存数据.取出数据以及 ...

  4. 《C++ Primer Plus 第六版》读书笔记

    CH1-3:处理数据 1 列表初始化 char c={31325}:不允许缩窄 char c={66}; char c={x}:不能为变量 2 强制类型转换 (typename) value type ...

  5. SMG12232ZK标准字符点阵型液晶显示模块的演示程序[C51编程语言][MCS51并行接口方式]

    //SMG12232ZK标准字符点阵型液晶显示模块的演示程序[C51编程语言][MCS51并行接口方式] //应用产品: SMG12232ZK标准中文字符点阵型液晶显示模块 // 本演示程序适用于SM ...

  6. In place Merge(原地归并)

    数组al[0,mid-1] 和 al[mid,num-1],都分别有序.将其merge成有序数组al[0,num-1],要求空间复杂度O(1) 思路:一般的归并是需要O(n)的空间,而这里要求空间复杂 ...

  7. NOIP2005 谁拿了最多奖学金

    1谁拿了最多奖学金 (scholar.pas/c/cpp) [问题描述] 某校的惯例是在每学期的期末考试之后发放奖学金.发放的奖学金共有五种,获取的条件各自不同: 1)     院士奖学金,每人800 ...

  8. C#进程同名的问题

    当一个进程中,判断另一个进程存在还是不存在可以使用Process.GetProcessesByName()方法来判断.但是仅仅使用Name来做区分的话,是有问题的.如何能保证这个名称的进程就是所希望的 ...

  9. 【C语言】- 数据输出-printf( )和putchar( )

    格式化输出函数printf( ) printf( )功能: 向系统指定输出设备按指定的格式输入任意个任意类型的数据,并返回实际输出的字符数.若出错,将返回负数. printf( )使用形式: prin ...

  10. hdoj 2544 最短路【dijkstra or spfa】

    最短路 Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...