Codeforces Round #478 Div2 975A 975B 975C 975D
A. Aramic script
题目大意:
\ 对于每个单词,定义一种集合,这个集合包含且仅包含单词中出现的字母。给你一堆单词,问有多少种这种集合。
题解:
\ 状压,插入set,取size
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <set>
#include <cmath>
inline int max(int a, int b){return a > b ? a : b;}
inline int min(int a, int b){return a < b ? a : b;}
inline int abs(int x){return x < 0 ? -x : x;}
inline void swap(int &x, int &y){int tmp = x;x = y;y = tmp;}
inline void read(int &x)
{
x = 0;char ch = getchar(), c = ch;
while(ch < '0' || ch > '9') c = ch, ch = getchar();
while(ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
if(c == '-') x = -x;
}
const int INF = 0x3f3f3f3f;
int n, cnt;
char s[1010];
std::set<int> st;
int main()
{
read(n);
for(int i = 1;i <= n;++ i)
{
scanf("%s", s + 1), cnt = 0;
for(int j = 1;s[j] != '\0';++ j)
cnt |= (1 << (s[j] - 'a'));
st.insert(cnt);
}
printf("%d", st.size());
return 0;
}
B. Mancala
题目大意:
\ 14个孔,孔里有一些小球。选择一个孔i,拿出里面所有球,一个一个依次往i,(i+1),(i+2)。。。。到14后,再从1,2,3,........无限循环下去,直到拿出来的求被放回去。14个孔里,个数为偶数的个数和就是分值。问最大分值。
题解:
\ 枚举哪个空,%14后的求暴力模拟,然后求答案。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <cmath>
inline long long max(long long a, long long b){return a > b ? a : b;}
inline long long min(long long a, long long b){return a < b ? a : b;}
inline long long abs(long long x){return x < 0 ? -x : x;}
inline void swap(long long &x, long long &y){long long tmp = x;x = y;y = tmp;}
inline void read(long long &x)
{
x = 0;char ch = getchar(), c = ch;
while(ch < '0' || ch > '9') c = ch, ch = getchar();
while(ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
if(c == '-') x = -x;
}
const long long INF = 0x3f3f3f3f;
long long num[20], tmp[20], tot, ans, cnt;
int main()
{
for(long long i = 1;i <= 14;++ i) read(num[i]);
for(long long i = 1;i <= 14;++ i)
{
tot = cnt = 0;
for(long long j = 1;j <= 14;++ j) tmp[j] = num[j];
tot += tmp[i] / 14, tmp[i] %= 14;
for(long long j = i + 1;j <= 14 && tmp[i];++ j) -- tmp[i], ++ tmp[j];
for(long long j = 1;j < i && tmp[i];++ j) -- tmp[i], ++ tmp[j];
for(long long j = 1;j <= 14;++ j)
if((tot + tmp[j]) % 2 == 0)
cnt += tot + tmp[j];
ans = max(ans, cnt);
}
printf("%I64d", ans);
return 0;
}
C. Valhalla Siege
题目大意:
\ \(n\)个士兵排成一列,每个士兵有血量\(a_i\),\(q\)分钟,每分钟对士兵造成共计\(k_i\)点伤害。即若第一个士兵血量归零,当前分钟剩余伤害则给第二个士兵,以此类推。当士兵全部死亡时,剩余的伤害会全部落空,而后士兵会全部复活。问每一分钟伤害造成后剩余多少士兵。
题解:
\ 求\(a\)的前缀和,二分模拟即可。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
inline long long max(long long a, long long b){return a > b ? a : b;}
inline long long min(long long a, long long b){return a < b ? a : b;}
inline long long abs(long long x){return x < 0 ? -x : x;}
inline void swap(long long &x, long long &y){long long tmp = x;x = y;y = tmp;}
inline void read(long long &x)
{
x = 0;char ch = getchar(), c = ch;
while(ch < '0' || ch > '9') c = ch, ch = getchar();
while(ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
if(c == '-') x = -x;
}
const long long INF = 0x3f3f3f3f;
long long n, q, a[200010], k[200010], tot, p;
int main()
{
read(n), read(q);
for(long long i = 1;i <= n;++ i) read(a[i]), a[i] += a[i - 1];
for(long long i = 1;i <= q;++ i)
{
read(k[i]);
p = std::lower_bound(a + 1, a + 1 + n, tot + k[i]) - a;
if(a[p] != tot + k[i]) -- p;
if(p >= n) printf("%I64d\n", n), tot = 0;
else printf("%I64d\n", n - p), tot += k[i];
}
return 0;
}
D. Ghosts
题目大意
\ 给定一条直线\(y=ax+b\),直线上有一些点,每个点都有运动速度,运动时间无限,问有多少点能相遇。
题解
\ 对于任意两个点\((x_1, y_1),(, x_2, y_2)\),时间为\(t\),若他们速度分别为\((v_{x1}, v_{y1}), (v_{x2}, v_{y2})\),速度完全相等时不可能相交,不完全相等时,若能相交,则有:
\]
\]
联立可得:
两点式:
$$y_1 - y_2 = a(x_1 - x_2)$$ ②
联立①②,有:
$$v_{y_1} - av_{x_1}=v_{y_2}-ax_{x_2}\]
于是只需统计满足上式的对数,减去速度完全相等的点的对数(速度完全相等的点显然也满足上式),即为答案。
用两个map记录。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
inline long long max(long long a, long long b){return a > b ? a : b;}
inline long long min(long long a, long long b){return a < b ? a : b;}
inline long long abs(long long x){return x < 0 ? -x : x;}
inline void swap(long long &x, long long &y){long long tmp = x;x = y;y = tmp;}
inline void read(long long &x)
{
x = 0;char ch = getchar(), c = ch;
while(ch < '0' || ch > '9') c = ch, ch = getchar();
while(ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
if(c == '-') x = -x;
}
const long long INF = 0x3f3f3f3f;
std::map<std::pair<long long, long long>, long long> mp2;
std::map<long long, long long> mp1;
long long n, a, b, x, vx, vy, ans, tmp;
int main()
{
read(n), read(a), read(b);
for(long long i = 1;i <= n;++ i)
{
read(x), read(vx), read(vy);
ans += mp1[vy - a * vx];
++ mp1[vy - a * vx];
ans -= mp2[std::make_pair(vx, vy)];
++ mp2[std::make_pair(vx, vy)];
}
printf("%I64d", ans << 1);
return 0;
}
Codeforces Round #478 Div2 975A 975B 975C 975D的更多相关文章
- Codeforces Round #539 div2
Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...
- 【前行】◇第3站◇ Codeforces Round #512 Div2
[第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...
- Codeforces Round#320 Div2 解题报告
Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...
- Codeforces Round #564(div2)
Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...
- Codeforces Round #361 div2
ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...
- Codeforces Round #626 Div2 D,E
比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...
- CodeForces Round 192 Div2
This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...
- Codeforces Round #359 div2
Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...
- Codeforces Round #360 div2
Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...
随机推荐
- PyQt5显示日期选择框,获取日期保存文件
一.UI显示选择日期,保存到文件 import sys,os from PyQt5 import QtCore from PyQt5.QtGui import * from PyQt5.QtWidge ...
- NX二次开发-UFUN创建圆柱UF_MODL_create_cyl1
NX9+VS2012 #include <uf.h> #include <uf_modl.h> #include <uf_obj.h> #include <u ...
- NX二次开发-相对路径环境变量和绝对路径环境变量
相对路径环境变量:${UGII_BASE_DIR}\CaesarToolkits 绝对路径环境变量:D:\Program Files\Siemens\NX 9.0\CaesarToolkits
- Java Heap and Stack
Heap(堆)(FIFO): heap是一个运行时数据区, 类的对象从中分配空间.这些对象通过new.newarray.anewarray和multianewarray等指令建立,它们不需要程序代码来 ...
- FZU - 2295 Human life:网络流-最大权闭合子图-二进制优化-第九届福建省大学生程序设计竞赛
目录 Catalog Solution: (有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 http://acm.fzu.edu.cn/problem.php?pid=2295 htt ...
- 英语影视台词---The Professor
英语影视台词---The Professor 一.总结 一句话总结: brilliant and liberty:厉害且自在 understand and forgive and not care:f ...
- Python中的动态类
Python中的动态类 有这样一个需求,我有SegmentReader.PostagReader.ConllReader这三个Reader,他们都继承于一个Reader类.在程序运行中,由用户通过se ...
- mysql查看数据库大小或者表大小
要想知道每个数据库的大小的话,步骤如下: 1.进入information_schema 数据库(存放了数据库的信息) use information_schema; 2.查询所有数据库的大小: sel ...
- 阿里云ecs(phpstudy一件包)
选择语言 保存并连接 Linux硬盘挂载是比较常见的管理操作之一.默认情况下数据盘没有挂载,需要手动挂载到系统中. 具体操作是分三步: 硬盘挂载1)需 ...
- C#中ORM的简单实现
ORM在功能上主要有两个: 把从数据库中查询返回的DataSet,DataTable转化为我们可以方便使用的实体类集合: 把要对数据库操作的实体类集合或条件转化为数据库可以直接执行的SQL语句.