A

/* Huyyt */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string a[];
int num[];
map<ll, int> mp;
int main()
{
int n;
cin >> n;
for (int i = ; i <= n; i++)
{
cin >> a[i];
}
int anser = ;
for (int i = ; i <= n; i++)
{
memset(num, , sizeof(num));
int now = ;
for (int j = ; j < a[i].size(); j++)
{
int cur = a[i][j] - 'a';
if (!num[cur])
{
num[cur] = ;
now += (1LL << cur);
}
}
if (!mp[now])
{
anser++;
mp[now]++;
}
}
cout << anser << endl;
}

B

/* Huyyt */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string a[];
ll num[];
ll ans[];
int main()
{
ll anser = ;
for (int i = ; i <= ; i++)
{
cin >> num[i];
}
for (int i = ; i <= ; i++)
{
ll now = ;
ll has;
for (int j = ; j <= ; j++)
{
ans[j] = num[j];
}
if (ans[i] == )
{
continue;
}
if (ans[i] >= )
{
ll bei = ans[i] / ;
has = ans[i] - * bei;
ans[i] = ;
for (int j = ; j <= ; j++)
{
ans[j] += bei;
}
int cur = i + ;
if (cur > )
{
cur -= ;
}
while (has)
{
ans[cur]++;
cur++;
if (cur > )
{
cur -= ;
}
has--;
}
}
else
{
has = ans[i];
ans[i] = ;
int cur = i + ;
if (cur > )
{
cur -= ;
}
while (has)
{
ans[cur]++;
cur++;
if (cur > )
{
cur -= ;
}
has--;
}
}
for (int j = ; j <= ; j++)
{
if (ans[j] % == )
{
now += ans[j];
}
}
anser = max(now, anser);
}
cout << anser << endl;
}

C

前缀和+二分

/* Huyyt */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m;
ll num[];
int getans(ll x)
{
int l = , r = n;
int mid, ans;
while (l <= r)
{
mid = (l + r) / ;
if (num[mid] > x)
{
ans = mid;
r = mid - ;
}
else
{
l = mid + ;
}
}
return ans;
}
int main()
{
ll now = ;
ll q;
cin >> n >> m;
for (int i = ; i <= n; i++)
{
cin >> num[i];
num[i] += num[i - ];
}
for (int i = ; i <= m; i++)
{
cin >> q;
now += q;
if (now >= num[n])
{
cout << n << endl;
now = ;
}
else
{
cout << n + - getans(now) << endl;
}
}
}

D

将点以离开原来所在直线的速度排序 相同速度的为一团

当且仅当两个速度方向一样(Vxi=Vxj Vyi=Vyj)的时候不会相交

/* Huyyt */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll cheng = ;
ll dian[];
ll k, anser;
ll sum = ;
ll kb;
ll vx, vy;
map<ll, ll> mp;
int main()
{
int n, m;
cin >> n;
cin >> k >> kb;
for (int i = ; i <= n; i++)
{
cin >> kb >> vx >> vy;
sum = 1LL * vx * (1LL * cheng + );
sum += vy;
anser -= 2LL * mp[sum];
mp[sum]++;
dian[i] = 1LL * vx * k - vy;
}
sum = ;
sort(dian + , dian + n + );
for (int i = ; i <= n; i++)
{
if (dian[i] == dian[i - ])
{
sum++;
}
else
{
anser += 1LL * sum * (sum - );
sum = ;
}
}
ll add = 1LL * sum * (sum - );
anser += add;
cout << anser << endl;
}

Codeforces 975 前缀和二分算存活人数 思维离直线速度相同判平行的更多相关文章

  1. Codeforces 948 数论推导 融雪前缀和二分check 01字典树带删除

    A. 全部空的放狗 B. 先O(NLOGNLOGN)处理出一个合数质因数中最大的质数是多少 因为p1 x1 x2的关系是 x2是p在x1之上的最小倍数 所以x1的范围是[x2-p+1,x2-1]要使最 ...

  2. Codeforces 1090J $kmp+hash+$二分

    题意 给出两个字符串\(s\)和\(t\),设\(S\)为\(s\)的任意一个非空前缀,\(T\)为\(t\)的任意一个非空前缀,问\(S+T\)有多少种不同的可能. Solution 看了一圈,感觉 ...

  3. [Codeforces 1199C]MP3(离散化+二分答案)

    [Codeforces 1199C]MP3(离散化+二分答案) 题面 给出一个长度为n的序列\(a_i\)和常数I,定义一次操作[l,r]可以把序列中<l的数全部变成l,>r的数全部变成r ...

  4. Glider(前缀和+二分)

    题目链接:Glider Gym-101911B 解题分析:下落的高度一定,是h.在没有气流的地方每秒下落1:所以可以转化为经过无气流地带的时间总长为h. 那么很显然从一个有气流地带的开始,选择下落,那 ...

  5. Acwing:102. 最佳牛围栏(前缀和 + 二分)

    农夫约翰的农场由 NN 块田地组成,每块地里都有一定数量的牛,其数量不会少于1头,也不会超过2000头. 约翰希望用围栏将一部分连续的田地围起来,并使得围起来的区域内每块地包含的牛的数量的平均值达到最 ...

  6. Educational Codeforces Round 11 C. Hard Process 前缀和+二分

    题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[ ...

  7. Codeforces Global Round 2 D 差分 + 前缀和 + 二分

    https://codeforces.com/contest/1119/problem/D 题意 有n个数组,每个数组大小为\(10^{18}+1\)且为等差数列,给出n个数组的\(s[i]\),q次 ...

  8. Codeforces 954 dijsktra 离散化矩阵快速幂DP 前缀和二分check

    A B C D 给你一个联通图 给定S,T 要求你加一条边使得ST的最短距离不会减少 问你有多少种方法 因为N<=1000 所以N^2枚举边数 迪杰斯特拉两次 求出Sdis 和 Tdis 如果d ...

  9. CodeForces - 948C(前缀和 + 二分)

    链接:CodeForces - 948C 题意:N天,每天生产一堆雪体积 V[i] ,每天每堆雪融化 T[i],问每天融化了多少雪. 题解:对 T 求前缀和,求每一堆雪能熬过多少天,再记录一下多余的就 ...

随机推荐

  1. 阶段3 2.Spring_06.Spring的新注解_6 Qualifier注解的另一种用法

    复制上面的数据源到下面改改名字 现在就是有两个数据源 创建一个eesy02的数据库 找到sql语句再创建Account表 现在就相当于有连个库一个eesy一个是eesy02这连个库. account里 ...

  2. Elasticsearch 6.2.3版本 Windows环境 简单操作

    背景描述 Elasticsearch是一个基于Apache Lucene(TM)的开源搜索引擎.无论在开源还是专有领域,Lucene可以被认为是迄今为止最先进.性能最好的.功能最全的搜索引擎库. El ...

  3. JS获取表单元素的value

    <!-- 1.option selected属性,如果我们在下拉列表里面选择了一个option那么他的selected="true" ,如果我们想设置当前的option是选中 ...

  4. JS ----- 底层原理

    什么是JS JavaScript是一种基于对象的动态.弱类型脚本语言(简称JS),是一种解释型语言,和其他的编程语言不同,如java/C++等编译型语言,这些语言在代码执行前会进行通篇编译,先编译成字 ...

  5. [百度百科]PCI-E的速度

    在早期开发中,PCIe最初被称为HSI(用于高速互连),并在最终确定其PCI-SIG名称PCI Express之前,将其名称更改为3GIO(第三代I / O). 名为阿拉帕霍工作组(AWG)的技术工作 ...

  6. SpringBoot_01

    一.初识springboot 个人总结:springboot是一个开发更加便捷的spring的技术框架,通过引入启动器便可以快捷的让spring框架和其他框架进行整合, springboot很容易上手 ...

  7. Microsoft BarCode Control 16.0属性

    Labview(2018)可通过Active调用Microsoft BarCode Control 16.0来生成条形码, 参考资料如下: 生成效果: 二维码: 条形码: 执行程序发现修改线条宽度不影 ...

  8. 实例学习——爬取Pexels高清图片

    近来学习爬取Pexels图片时,发现书上代码会抛出ConnectionError,经查阅资料知,可能是向网页申请过于频繁被禁,可使用time.sleep(),减缓爬取速度,但考虑到爬取数据较多,运行时 ...

  9. python-day11(正式学习)

    目录 文件高级应用 多重操作 r+t:可读,可写(文件名为a) w+t:可写可读 a+t:可追加可读 文件内指针移动及一些操作 指针移动seek(offset,whence) 寻找指针位置tell() ...

  10. python中的生成器、迭代器、闭包、装饰器

    迭代器 迭代是访问集合元素的一种方式.迭代器是一个可以记住遍历的位置的对象.迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束.迭代器只能往前不会后退. 可迭代对象 以直接作用于 for ...