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> # ...
随机推荐
- jQuery动画流程分析
- C#创建UTF8无BOM文本文件
In order to omit the byte order mark (BOM), your stream must use a custom instance of UTF8Encoding i ...
- VMware workstation 的虚拟机中再安装workstation
在VMware workstation 10中运行的虚拟机中再安装workstation软件时,启动时会出现不断重启的故障, 解决办法: 在宿主虚拟机的.vmx文件中添加一行 monitor_cont ...
- Raphaël 是一个小型的 JavaScript 库,用来简化在页面上显示向量图的工作。你可以用它在页面上绘制各种图表、并进行图片的剪切、旋转等操作。
点这里 在线效果演示:http://raphaeljs.com/pie.html http://raphaeljs.com github: https://github.com/DmitryBaran ...
- ExtJs之Ext.each
<!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv ...
- 消除ComponentOne(C1StudioNet_2013v2) 的注册提示
以后大家如果遇到还有提示,在License文件里添加:C1.Win.C1Command.C1OutBar, C1.Win.C1Command.4, Version=4.0.20132.19568, ...
- SQL Server 基础 之 GROUP BY子句
GROUP BY 子句用于聚合信息 先看个实例,没有使用 GROUP BY 子句 SELECT SalesOrderID,OrderQty FROM Sales.SalesOrderDetail WH ...
- (1)搭建opencv-android环境
前言: 本文目的是指导在windows平台搭建一个opencv for android 的开发环境,作者参考了很多网上的教程,本文所使用的各种软件.插件都是截止到写这篇文章的最新版本,作者在实际搭建环 ...
- INTERESTING AND OBSCURE INHERITANCE ISSUES WITH CPP
1. using 关键字 使用 using 关键字,可以将父类中被隐藏的函数暴露在子类中,但是需要注意的是,在相同情况下,子类函数的优先级更高. 2. 继承构造函数(C++11) 在c++11之前, ...
- JDBC第四次学习
传智播客李勇老师的JDBC系列学习终于接近尾声了,好开心,能学到这么多的东西,还不赶快记录下来,留待以后回味! 如何使用开源项目DBCP(实际项目中常用) 主要分为三个步骤: 使用DBCP必须用 ...