Codeforces_794
A.统计两个guard之间的钞票数。
#include<bits/stdc++.h>
#define MOD 1000000009
using namespace std; int a,b,c,n; int main()
{
ios::sync_with_stdio(false);
cin >> a >> b >> c >> n;
int ans = ;
while(n--)
{
int x;
cin >> x;
if(b < x && x < c) ans++;
}
cout << ans << endl;
return ;
}
B.面积x倍,边长sqrt(x)倍。
#include<bits/stdc++.h>
#define MOD 1000000009
using namespace std; int n,h; int main()
{
ios::sync_with_stdio(false);
cin >> n >> h;
for(int i = ;i < n;i++)
{
cout << fixed << setprecision() << h*sqrt(1.0*i/n) << " ";
}
cout << endl;
return ;
}
C.首先可以得知,选取s1中最小的(n+1)/2个,s2中最大的n/2个,整个过程有以下两步骤。
1.当s1中最小的比s2中最小的要小是,显然,s1每次选最小的放在串首,s2每次选最小的放在串首。
2.否则,s1每次选最大的放在串尾,s2每次选最大的放在串尾。
#include<bits/stdc++.h>
using namespace std; string s1,s2; int main()
{
ios::sync_with_stdio(false);
cin >> s1;
sort(s1.begin(),s1.end());
cin >> s2;
sort(s2.begin(),s2.end());
reverse(s2.begin(),s2.end());
int n = (s1.length()+)/,m = s1.length()/;
int now1 = ,now2 = ;
char ans[] = {};
int num = ,l = ,r = s1.length()-;
while(num < s1.length() && s1[now1] < s2[now2])
{
if(num% == ) ans[l++] = s1[now1++];
else ans[l++] = s2[now2++];
num++;
}
now1 = n-,now2 = m-;
while(num < s1.length())
{
if(num% == ) ans[r--] = s1[now1--];
else ans[r--] = s2[now2--];
num++;
}
cout << ans << endl;
return ;
}
D.用hash缩点,之后的图每个点最多只能有两条边,dfs。
#include<bits/stdc++.h>
using namespace std; int n,m;
int hashh[],pre[],ans[] = {},vis[] = {},visc[] = {};
vector <int> v[]; void dfs(int now)
{
vis[now] = true;
if(ans[now] == ) return;
for(int i = ;i < v[now].size();i++)
{
int t = v[now][i];
if(hashh[t] == hashh[now]) ans[t] = ans[now];
}
for(int i = ;i < v[now].size();i++)
{
int t = v[now][i];
if(vis[t]) continue;
if(!ans[t])
{
if(!visc[ans[now]-])
{
visc[ans[now]-] = ;
ans[t] = ans[now]-;
}
else if(!visc[ans[now]+])
{
visc[ans[now]+] = ;
ans[t] = ans[now]+;
}
}
dfs(t);
}
} int main()
{
ios::sync_with_stdio();
cin >> n >> m;
pre[] = ;
for(int i = ;i <= n;i++) pre[i] = pre[i-]*+i;
for(int i = ;i <= n;i++) hashh[i] = pre[i];
for(int i = ;i <= m;i++)
{
int x,y;
cin >> x >> y;
v[x].push_back(y);
v[y].push_back(x);
hashh[x] += pre[y];
hashh[y] += pre[x];
}
ans[] = ;
visc[] = ;
dfs();
for(int i=;i<=n;i++)
{
if(!ans[i])
{
cout << "NO" << endl;
return ;
}
}
cout << "YES" << endl;
for(int i = ;i <= n;i++) cout << ans[i] << " ";
cout << endl;
return ;
}
Codeforces_794的更多相关文章
随机推荐
- linux下安装mysql5.7.25详细教程
前言 最近项目上线,开始给用户测试了.搞下来好多台服务器,自然要装一个mysql的服务器.想想广大博友应该都会遇到如何装mysql的问题,就此分享,给大家一个安装指南.供大家以后安装的时候,提高效率, ...
- 【转】Java多线程面试问题集锦
如果你即将去一家从事大型系统研发的公司进行Java面试,不可避免的会有多线程相关的问题.下面是一些针对初学者或者新手的问题,如果你已经具备良好的基础,那么你可以跳过本文,直接尝试针对进阶水平的Java ...
- Spring Boot2 系列教程 (六) | 使用 JdbcTemplates 访问 Mysql
前言 如题,今天介绍 springboot 通过jdbc访问关系型mysql,通过 spring 的 JdbcTemplate 去访问. 准备工作 SpringBoot 2.x jdk 1.8 mav ...
- HTML中使用Vue+Dhtmlxgantt制作任务进度图
HTML中使用Vue+Dhtmlxgantt制作任务进度图 Dhtmlxgantt官网: https://dhtmlx.com/docs/products/dhtmlxGantt/ 参考文章 甘特图配 ...
- numpy 其它常用方法
一.创建特殊的数组 1.ones() 语法 np.ones(shape, dtype=None) # shape 创建数组的shape # dtype 指定数组的数据类型 例子 import nump ...
- Scrapy深度和优先级
一.深度 配置文件 settings.py DEPTH_LIMIT = 5 二.优先级 配置文件 DEPTH_PRIORITY=1 优先级为正数时,随着深度越大,优先级越低 源码中,优先级 reque ...
- CBV 序列化
一.模型表 from django.db import models # Create your models here. class Publish(models.Model): name = mo ...
- moco响应中文乱码
moco版本为:moco-runner-standalone-0.11.1.jar 在一次使用moco框架的时候,浏览器查看响应时,发现返回来的中文是乱码. 按照网上的操作,在响应结果中加上heade ...
- Beat our dice game and get the flag 击败我们的骰子游戏拿到旗子
文件名:ebCTF-Teaser-BIN100-Dice.exe 话不多说 用PEID一看没壳 拖进OD 让我们摇出31337这五个数字才能拿到正确的flag cmp dword ptr ss:[eb ...
- 第二阶段冲刺个人任务——five
今日任务: 合并程序(统计团队博客). 昨日成果: 优化统计团队博客结果界面的显示.