#291 div.2
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的更多相关文章
- hash+set Codeforces Round #291 (Div. 2) C. Watto and Mechanism
题目传送门 /* hash+set:首先把各个字符串的哈希值保存在set容器里,然后对于查询的每一个字符串的每一位进行枚举 用set的find函数查找是否存在替换后的字符串,理解后并不难.另外,我想用 ...
- 暴力/set Codeforces Round #291 (Div. 2) C. Watto and Mechanism
题目传送门 /* set的二分查找 如果数据规模小的话可以用O(n^2)的暴力想法 否则就只好一个一个的换(a, b, c),在set容器找相匹配的 */ #include <cstdio> ...
- 数学 Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun
题目传送门 /* 水题,就是用三点共线的式子来判断射击次数 */ #include <cstdio> #include <cmath> #include <string& ...
- 贪心/字符串处理 Codeforces Round #291 (Div. 2) A. Chewbaсca and Number
题目传送门 /* WA了好几次,除了第一次不知道string不用'\0'外 都是欠考虑造成的 */ #include <cstdio> #include <cmath> #in ...
- Codeforces Round #291 (Div. 2)
A 题意:给出变换规则,单个数字t可以变成9-t,然后给出一个数,问最小能够变成多少. 自己做的时候理解成了不能输出前导0,但是题目的本意是不能有前导0(即最高位不能是0,其余位数按照规则就好) 55 ...
- Codeforces Round #291 (Div. 2) C - Watto and Mechanism 字符串
[题意]给n个字符串组成的集合,然后有m个询问(0 ≤ n ≤ 3·105, 0 ≤ m ≤ 3·105) ,每个询问都给出一个字符串s,问集合中是否存在一个字符串t,使得s和t长度相同,并且仅有一个 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- EF5.0修改实体的时候,出现“对一个或多个实体的验证失败。有关详细信息,请参见“EntityValidationErrors”属性这个错误
对于这个错误,要在SaveChanges前关闭验证实体有效性(ValidateOnSaveEnabled)这个开关 db.Configuration.ValidateOnSaveEnabled = f ...
- 工具http://www.architexa.com/learn-more/install使用
准备写篇博客,用来研究开源软件的利器.
- Extjs4 页数重置
重新加载数据store.loadPage(1);就是到第一页了
- Sort--冒泡排序
冒泡排序 public class BubbleSort { public static void bubblesort(int[] a){ for(int i=0;i<a.length-1;i ...
- Thinking in Java
今天无意中看到了这本书(Thinking in Java)的中关于多态的一段描述,瞬间就感觉到了多态原来是这样的.
- leetcode@ [54/59] Spiral Matrix & Spiral Matrix II
https://leetcode.com/problems/spiral-matrix/ Given a matrix of m x n elements (m rows, n columns), r ...
- xml--通过SAX解析XML
SAX的全称是Simple APIs for XML,也即XML简单应用程序接口.与DOM不同,SAX提供的访问模式是一种顺序模式,这是一种快速读写XML数据的方式.当使用SAX分析器对XML文档进行 ...
- [struts2]jstl标签用法技巧
1.<c:if test="${var} != null"></c:if> 2. <c:foreach var="singleVar&quo ...
- Servlet过滤器理解
from:http://blog.csdn.net/microtong/article/details/5007170 过滤器(Filter)的概念 过滤器位于客户端和web应用程序之间,用于检查和修 ...
- glog摘记
projcet url:https://code.google.com/p/google-glog/ usage: application-level logging setting flags GL ...