https://www.cnblogs.com/31415926535x/p/10397007.html

codeforces 537 div2

A

题意就是给你两个字符串,然后如果s,t的对应位上的字母要么都是元音,要么都是辅音,,就输出Yes反之输出No,,长度不等肯定输出的是No,,,

#include <bits/stdc++.h>
//#include <iostream>
//#include <cstdio>
//#include <cstdlib>
//#include <string.h>
#define aaa cout<<ans<<endl;
#define endl '\n'
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;//1061109567
const ll linf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-6;
const double pi = 3.14159265358979;
const int maxn = 2e5 + 5;
const int maxm = 2e5 + 5;
const int mod = 1e9 + 7;
inline ll read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
bool check(char a, char b)
{
if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
if(b == 'a' || b == 'e' || b == 'i' || b == 'o' || b == 'u')
return true;
else
return false;
else if(b != 'a' && b != 'e' && b != 'i' && b != 'o' && b != 'u')return true;
else return false;
}
int main()
{
// freopen("233.in" , "r" , stdin);
// freopen("233.out" , "w" , stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
string s, t;cin >> s >> t;
if(s.length() != t.length())cout << "No" << endl;
else
{
int len = s.length();
for(int i = 0; i < len; ++i)
{
if(!check(s[i], t[i]))
{
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
return 0;
}

B

题意是给你n个数,有两种操作,一个是删除任意的一个数,另一个是将任意的一个数加一,,对于 每个数的操作 最多有k种,,总的操作数是m,,,然后问你m个操作后最大的平均值是多少,,

首先为了尽可能的增加平均数,要删除一些小的数,,暴力遍历可能删除的数的个数,,显然最多删除的个数是n-1或者是m,,所以遍历的边界是 min(m, n - 1),,

然后依次删去最小的数(预先排序一下),,删掉这个数后,算一下此时剩下数的平均值,,,然后和上一次的结果比较一下,取最大就行

#include <bits/stdc++.h>
//#include <iostream>
//#include <cstdio>
//#include <cstdlib>
//#include <string.h>
#define aaa cout<<233<<endl;
#define endl '\n'
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, ull> pii;
const int inf = 0x3f3f3f3f;//1061109567
const ll linf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-6;
const double pi = 3.14159265358979;
const int maxn = 1e5 + 5;
const int maxm = 2e5 + 5;
const ll mod = 1e9 + 7;
inline int read() //快读
{
int ans=0;
char ch=getchar();
while(!isdigit(ch))
ch=getchar();
while(isdigit(ch))
ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
return ans;
}
ll a[maxn]; int main()
{
// freopen("233.in" , "r" , stdin);
// freopen("233.out" , "w" , stdout);
// ios_base::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
ll n, k, m;
n = read(); k = read(); m = read();
for(int i = 1; i <= n; ++i)a[i] = read();
sort(a + 1, a + 1 + n);
ll sum = 0;
for(int i = 1; i <= n; ++i)sum += a[i];
long double ans = (long double)(sum + min(k * n, m)) / (long double)(n);
for(int i = 1; i <= min(m, n - 1); ++i)
{
sum -= a[i];
long double res = (long double)(sum + min(m - i, k * (n - i))) / (long double)(n - i);
ans = max(ans, res);
}
printf("%.20f", (double)ans);
return 0;
}

C

题意是给你一个区间长度为 \(2^n\)长,,然后一个数组a[k],a[i]表示第i个位置加一,,可能有a[i]是相等的,,然后有两种操作,一种是子区间全为零时操作的代价为A,,否则代价为 \(B*num_{l,r}*len_{l, r}\),,,问你整个区间的最小操作代价,,

题解是递归+二分求解,,,

我一开始想到了递归来求,,但是自己写二分求区间[l, r]的 \(num_{l, r}\) 时总是写爆,,,最后看了题解才想起来还有stl里的 lower_boundupper_bound 可以直接二分找到,,,QAQ

#include <bits/stdc++.h>
//#include <iostream>
//#include <cstdio>
//#include <cstdlib>
//#include <string.h>
#define aaa cout<<233<<endl;
#define endl '\n'
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, ull> pii;
const int inf = 0x3f3f3f3f;//1061109567
const ll linf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-6;
const double pi = 3.14159265358979;
const int maxn = 1e5 + 5;
const int maxm = 2e5 + 5;
const ll mod = 1e9 + 7;
inline ll read() //快读
{
ll ans=0;
char ch=getchar();
while(!isdigit(ch))
ch=getchar();
while(isdigit(ch))
ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
return ans;
}
vector<ll> a;
ll n, k, A, B;
#define len (r-l+1)
#define mid ((l+r)>>1)
ll getnum(int l, int r)
{
l = lower_bound(a.begin(), a.end(), l) - a.begin();
r = upper_bound(a.begin(), a.end(), r) - a.begin();
return r - 1 - l + 1;
}
ll solve(int l, int r)
{
ll num = getnum(l, r);
if(!num)return A;
if(l == r)
{
if(num)
return B * num * 1;
else
return A;
}
ll a = solve(l, mid);
ll b = solve(mid + 1, r);
// cout << a << b << "---" << endl;
if(num)return min(a+b, (ll)(B * len * num));
else return min(a+b, A);
} int main()
{
// freopen("233.in" , "r" , stdin);
// freopen("233.out" , "w" , stdout);
// ios_base::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
n = read(); k = read(); A = read(); B = read();
for(int i = 1; i <= k; ++i)
{
int t = read();
a.pb(t);
}
sort(a.begin(), a.end());
printf("%lld", solve(1, (1<<n)));
return 0;
}

codeforces-1111的更多相关文章

  1. Codeforces 1111 简要题解

    文章目录 A题 B题 C题 D题 E题 传送门 A题 传送门 题意简述:把262626个英文字母分成两类A,BA,BA,B,AAA类字符可以转成AAA类字符,BBB类字符可以转成BBB类字符,问给出的 ...

  2. Codeforces 1111 E. Tree(虚树,DP)

    题意 有一棵树,q个询问,每次询问,指定一个点做树根,再给定k个点,要求把这些点分成不超过m组的方案数,分配的限制是任意两个有祖先关系的点不能分在同一组.题目还保证了所有的询问的k加起来不超过1e5. ...

  3. Codeforces round 1111

    CF Div 2 537 比赛链接 感觉题目难度OK,五个题都能做,后俩题考察人的翻译水平... 另外,$Claris$太强了... A 直接按照题意模拟,不知道为啥有人会被× 代码: #includ ...

  4. codeforces contest 1111

    A. Superhero Transformation 题意: 元音和元音,辅音和辅音字母之间可以互相转换,问两个字符串是否想同: 题解:直接判断即可: #include<bits/stdc++ ...

  5. Codeforces 717G Underfail(最小费用最大流 + AC自动机)

    题目 Source http://codeforces.com/problemset/problem/717/G Description You have recently fallen throug ...

  6. codeforces Good Bye 2015 B. New Year and Old Property

    题目链接:http://codeforces.com/problemset/problem/611/B 题目意思:就是在 [a, b] 这个范围内(1 ≤ a ≤ b ≤ 10^18)统计出符合二进制 ...

  7. Codeforces Gym 100513G G. FacePalm Accounting

    G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513 ...

  8. Codeforces Round #309 (Div. 2) B. Ohana Cleans Up 字符串水题

    B. Ohana Cleans Up Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/pr ...

  9. Codeforces Beta Round #96 (Div. 1) D. Constants in the language of Shakespeare 贪心

    D. Constants in the language of Shakespeare Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codef ...

  10. CodeForces 554B(扫房间)

      CodeForces 554B Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u ...

随机推荐

  1. 基于vue-cli的eslint常用设置

    .editorconfig 文件详细备注 # 最顶级的配置,相当于根 editorconfig 直到查找到root=true 才会停止查找不然会一直向上查找 root = true # 通配符 表示匹 ...

  2. Dom4j向XML中增加节点与属性——(四)

    先获取到节点,然后在节点山添加Element 添加节点 添加属性 设置开始标签与结束标签的值book.addElement("描述").addAttribute("nam ...

  3. Jetson tk1 hash sum mismatch

    sudo apt-get update遭遇Hash Sum Mismatch 修改DNS服务器地址: sudo gedit /etc/resolv.conf 解决办法: 在装有goagent的情况下: ...

  4. centos6安装python3.6.4

    安装Python依赖包: [root@Python src]# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlit ...

  5. Python3学习笔记22-文件读写

    读写文件前,我们先必须了解一下,在磁盘上读写文件的功能都是由操作系统提供的,现代操作系统不允许普通的程序直接操作磁盘,所以,读写文件就是请求操作系统打开一个文件对象(通常称为文件描述符),然后,通过操 ...

  6. GitHub提交代码后不显示用户名只显示邮箱

    提交完代码如图: 解决方案: 右键git bash here 输入命令如下: git config --global user.name "username" git config ...

  7. appium运行报错java.net.SocketException: socket write error

    这个错我调了 快两天一点头绪没有,脚本正常跑没问题,但是就是控制台输出信息报错,没法定位问题在哪.报错如图: 虽然这个报错不影响测试结果,但是本人有强迫症,一定要查出究竟: 我的尝试: 1.那天试验, ...

  8. PYTHON-有参装饰器,无参装饰器,语法糖

    装饰器 装饰器就是闭包函数的一种应用场景 一 为何要用装饰器 #开放封闭原则:对修改封闭,对扩展开放 二 什么是装饰器 装饰器他人的器具,本身可以是任意可调用对象,被装饰者也可以是任意可调用对象. 强 ...

  9. Github之协同开发

    一.协同开发 1.引子:假如三个人共同开发同一份代码,每个人都各自安排了任务,当每个人都完成了一半的时候,提交不提交呢? 要提交,提交到dev吗,都上传了一半,这样回家拿出来的代码根本跑不起来.所以, ...

  10. Laravel Cache 的缓存文件在到期后是否会自动删除

    验证缓存文件是否会自动删除的目的是,防止产生大量的缓存文件,占满磁盘.因为,我最近越来越多的使用 cache 来缓存各类 token. 使用的是 file 作为 CACHE_DRIVER CACHE_ ...