第一题很水但是wa了一发,因为没考虑K前面是K的情况

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; bool vis[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
string s;
cin>>s;
int ans=;
for(int i=;i<s.size()-;i++)
{
if(s[i]=='V'&&s[i+]=='K')
{
vis[i]=vis[i+]=;
ans++,i++;
}
}
for(int i=;i<s.size()-;i++)
if(!vis[i]&&!vis[i+]&&s[i]=='V')
{
cout<<ans+<<endl;
return ;
}
for(int i=;i<s.size();i++)
if(!vis[i]&&!vis[i-]&&s[i]=='K')
{
cout<<ans+<<endl;
return ;
}
cout<<ans<<endl;
return ;
}

A

第二题也很水1a

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; int main()
{
ios::sync_with_stdio(false);
cin.tie();
string x,z,y="";
cin>>x>>z;
bool f=;
for(int i=;i<x.size();i++)
{
if(x[i]>=z[i])y+=z[i];
else f=;
}
if(f)cout<<-<<endl;
else cout<<y<<endl;
return ;
}

B

第三题因为精度问题,一直wa到最后。。。。最后看别人代码时发现用k记录二分的次数,次数够大就输出-1退出,居然还有这种骚操作,唉,我居然给忘记了

话说一开始就想到二分也不错了,虽然改了很多发还是wa在第74个点

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; double a[N],b[N],p;
int n;
bool ok(double x)
{
double s=,time=;
for(int i=;i<=n;i++)
{
if(b[i]-a[i]*x<)
{
time+=(a[i]*x-b[i])/p;
if(time>x)return ;
}
}
return ;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie();
cout<<setiosflags(ios::fixed)<<setprecision();
cin>>n>>p;
for(int i=;i<=n;i++)cin>>a[i]>>b[i];
double l=0.0,r=1e15+;
int ans=;
while(r-l>eps){
ans++;
if(ans>)
{
cout<<-<<endl;
return ;
}
double m=(l+r)/;
if(ok(m))l=m;
else r=m;
}
if(l>1e15)cout<<-<<endl;
else cout<<l<<endl;
return ;
}

C

第四题没想到会这么水,一开始想错了,后来看了样例的解释就明白了,枚举每个点到左右两边的距离的一半的最小值就是答案了

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; double x[N],y[N];
double dis(int a,int b,int c)
{
double B=sqrt((y[c]-y[a])*(y[c]-y[a])+(x[c]-x[a])*(x[c]-x[a]));
double A=(y[c]-y[a])*x[b]-(x[c]-x[a])*y[b]-(y[c]-y[a])*x[c]+(x[c]-x[a])*y[c];
double ans=A/B;
if(ans<)ans=-ans;
return ans/;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie();
cout<<setiosflags(ios::fixed)<<setprecision();
int n;
cin>>n;
for(int i=;i<=n;i++)cin>>x[i]>>y[i];
double ans=1e18;
for(int i=;i<=n;i++)
{
int x1=i-,x2=i,x3=i+;
if(x1==)x1=n;
if(x3==n+)x3=;
ans=min(ans,dis(x1,x2,x3));
}
cout<<ans<<endl;
return ;
}

D

Codeforces Round #409的更多相关文章

  1. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)(A.思维题,B.思维题)

    A. Vicious Keyboard time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...

  2. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) D. Volatile Kite

    地址:http://codeforces.com/contest/801/problem/D 题目: D. Volatile Kite time limit per test 2 seconds me ...

  3. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) C Voltage Keepsake

    地址:http://codeforces.com/contest/801/problem/C 题目: C. Voltage Keepsake time limit per test 2 seconds ...

  4. Codeforces Round #409 C. Voltage Keepsake(二分+思维)

    题目链接:http://codeforces.com/contest/801/problem/C 题意:给出一个充电器每秒钟充p个点,还有n个电器要同时使用a[i]表示第i个电器每秒钟用多少点,b[i ...

  5. Codeforces Round#409/VK-Cup 2017 Round2

    来自FallDream的博客,未经允许,请勿转载,谢谢. 和ditoly组队打VK-Cup,起了个名字叫Vegetable Chicken(意思显然),然后昨天我做AB他切C 很不幸的是.....我写 ...

  6. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) 题解【ABCDE】

    A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后c ...

  7. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)

    A 每次可以换一个或不换,暴力枚举位置即可 B 模拟 C 二分答案.. 边界可以优化r=totb/(tota-p),二分可以直接(r-l>=EPS,EPS不要太小,合适就好),也可以直接限定二分 ...

  8. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A B C D 暴力 水 二分 几何

    A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #409(Div.2)

    传送门 题意 A.询问最多改变一个字符的字符串"VK"子串数量 B.f(x,z)=y,给出x,y,求z For example, f("ab", "b ...

随机推荐

  1. 5、RabbitMQ - Exchange之 fanout \ 【direct 关键字发送】 \ topic

    pytho系列之 RabbitMQ - Exchange几种模式 RabbitMQ中,所有生产者提交的消息都由Exchange来接受,然后Exchange按照特定的策略转发到Queue进行存储 Rab ...

  2. 爬虫——请求库之selenium模块

      阅读目录 一 介绍 二 安装 三 基本使用 四 选择器 五 等待元素被加载 六 元素交互操作 七 其他 八 项目练习 一 介绍 selenium最初是一个自动化测试工具,而爬虫中使用它主要是为了解 ...

  3. ionic调用摄像头

    须知ionic是借助于cordova来实现与底层硬件的交互的 我假设你已经全局安装了cnpm.ionic.cordova,并且配置好了安卓环境 我以下demo是建立在官方提供的模板上进行的ionic ...

  4. HYSBZ - 2818 Gcd (莫比乌斯反演)

    莫比乌斯反演的入门题,设 \(F(x): gcd(i,j)\%x=0\) 的对数,\(f(x): gcd(i,j)=x\)的对数. 易知\[F(p) = \lfloor \frac{n}{p} \rf ...

  5. Linux数据备份与恢复

    Linux数据备份及服务器重要数据类别分析 对 Linux 服务器来讲,当然最理想的就是把整块硬盘中的数据都备份,甚至连分区和文件系统都备份,这样如果硬盘损坏,那么我们可以直接把备份硬盘中的数据导入损 ...

  6. 【c++ primer, 5e】函数声明 & 分离式编译

    p186~p188: 函数声明1.函数只能定义一次,但是可以声明多次. 2.函数的接口:返回类型 + 函数名 + 形参类型 3.为什么要在头文件中进行函数声明???在源文件中定义?暂时理解到,这么做可 ...

  7. Cisco 交换Trunk配置

    交换Trunk配置 #进入直连端口下 config)#int f0/1 #配置trunk封装协议 config)#switchport trunk encapsulation dot1q #配置为tr ...

  8. Swift日常开发随笔

    1.修改UISearchBar的搜索框底色 使用以下代码: setSearchFieldBackgroundImage(CommonUseClass._sharedManager.imageFromC ...

  9. cogs 539. 牛棚的灯

    ★★☆   输入文件:lights.in   输出文件:lights.out   简单对比 时间限制:1 s   内存限制:128 MB [问题描述] 贝希和她的闺密们在她们的牛棚中玩游戏.但是天不从 ...

  10. Python学习笔记(十二)—Python3中pip包管理工具的安装【转】

    本文转载自:https://blog.csdn.net/sinat_14849739/article/details/79101529 版权声明:本文为博主原创文章,未经博主允许不得转载. https ...