Codeforces Round #291 (Div. 2)
A
题意:给出变换规则,单个数字t可以变成9-t,然后给出一个数,问最小能够变成多少。
自己做的时候理解成了不能输出前导0,但是题目的本意是不能有前导0(即最高位不能是0,其余位数按照规则就好) 555555---读题仔细o(╯□╰)o
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[];
int main() {
int len,i;
scanf("%s",s);
len=strlen(s);
for(i=;i<len;i++)
{
if(s[i]>'') s[i]=''+''-s[i];
}
if(s[]=='') s[]='';
else
{
if(s[]>'') s[]=''+''-s[];
}
puts(s);
}
B
题意:给出n个坐标,以及一个起始的坐标,问能够构成多少条斜率不同的直线
自己做的时候没有把斜率不存在的情况考虑进去,而且最后找出有多少条斜率不同的直线也没有写对-----
最后看的题解,学习了map函数===就好写了----
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
map<double,int>key;
int main()
{
int n,flag=;
double a,b,x,y,m;
cin>>n>>x>>y;
for(int i=;i<n;i++)
{
cin>>a>>b;
if(a==x) flag=;//分母为0即斜率不存在的时候单独考虑
else key[(y-b)/(x-a)]=;
}
printf("%d\n",key.size()+flag);
}
C
题意:先给出n个字符串,再给出n个串查询,问是否存在只有一个位置的字母不同其余的都相同的字符串
还是不会====字典树======挖坑====
Codeforces Round #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) 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 ...
- Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun
因为是x,y均为整数因此对于同一直线的点,其最简分数x/y是相同的(y可以为0,这里不做除法)于是将这些点不断求最简分数用pair在set中去重即可. #include <cmath> # ...
随机推荐
- DirectShow 最简单的入门 -- 播放一段视频
#include <dshow.h> #pragma comment(lib,"strmbase.lib") #pragma comment(lib,"qua ...
- HDU 1163 Eddy's digital Roots(模)
HDU 1163 题意简单,求n^n的(1)各数位的和,一旦和大于9,和再重复步骤(1),直到和小于10. //方法一:就是求模9的余数嘛! (228) leizh007 2012-03-26 21: ...
- 安装mysql之后,存入中文出现乱码 02
现在出现这个问题,将编码字符串改成utf8 之后 数据表 还是不能存储中文. 看如下两张图,应该会有启发: 这下应该明白了吧.
- java系统属性
java系统属性 1. java.runtime.name:java的运行环境名称. 2. sun.boot.library.path:jdk\jre中的bin的路径 3. java.vm.versi ...
- Codeforces Round #336 (Div. 2) D. Zuma 区间dp
D. Zuma Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gems ...
- JS面向(基于)对象编程--三大特征
抽象 在讲解面向对象编程的三大特征前,我们先了解什么叫抽象,在定义一个类时候,实际上就是把一类事物的共有的属性和行为提取出来,形成一个物理模型(模板).这种研究问题的方法称为抽象. 封装 什么是封装? ...
- copy
拷贝文件,不覆盖重复文件 yes no|cp -i a b
- 浅析C/C++ library
1 背景 原来跑的好好的进程,重启后没跑多少就挂掉了,奇怪了.经过跟踪,原来是加载了一个.so文件,于是决定学习一下library相关的东东,现在和大家分享一下. 2 分类 C/C++ library ...
- Mysql Workbench 学习
1.安装 http://dev.mysql.com/downloads/tools/workbench/ 选择合适的,下载(以Ubuntu 为例) cd到下载目录,然后sudo dpkg -i wor ...
- Linux下Websphere无法关闭
Websphere 启动关闭命令 linux 下首先查看进程 ./stopServcer.sh server1如果停不掉websphere服务.则强制杀掉其进程! 1.查看websphere进程号b ...