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. NOIP2009 最优贸易

    3. 最优贸易 (trade.pas/c/cpp) [问题描述] C 国有 n 个大城市和 m 条道路,每条道路连接这 n 个城市中的某两个城市.任意两个城市之间 多只有一条道路直接相连.这 m 条道 ...

  2. Magento 处理方法

    1.在模板中添加图片: <div id="header-image" class="skip-image"> <img src="& ...

  3. OWC控件的使用

    环境:SQL Server 2005  Analysis Services + OWC 1.1 +Win 7 准备: 1.在SQL Server 2005 Analysis Services建好ola ...

  4. window2008 64位系统没有office组件问题分析及解决

    服务器是windows server2008 64位系统, 我的系统需要用到Microsoft.Office.Interop.Excel组件 在上传Excel单据遇到错误:检索 COM 类工厂中 CL ...

  5. A Tour of Go Exercise: HTTP Handlers

    Implement the following types and define ServeHTTP methods on them. Register them to handle specific ...

  6. UIKit: UIResponder(转自南峰子博客)

    有问题可以加本人QQ:564702640(验证:博客园) 我们的App与用户进行交互,基本上是依赖于各种各样的事件.例如,用户点击界面上的按钮,我们需要触发一个按钮点击事件,并进行相应的处理,以给用户 ...

  7. 转载 GUID介绍

    转载 http://www.cnblogs.com/illele/archive/2008/02/25/1080554.html GUID(Global unique identifier)全局唯一标 ...

  8. 剑指OFFER之第一个只出现一次的字符(九度OJ1283)

    题目描述: 在一个字符串(1<=字符串长度<=10000,全部由大写字母组成)中找到第一个只出现一次的字符. 输入: 输入有多组数据每一组输入一个字符串. 输出: 输出第一个只出现一次的字 ...

  9. tomcat 6.0 压缩功能

    官方文档: http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

  10. ASP.net中的Cache使用介绍

    1.1.1 摘要(http://www.cnblogs.com/rush/archive/2012/06/30/2571438.html) 最近我们的系统面临着严峻性能瓶颈问题,这是由于访问量增加,客 ...