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也算赢. 现 ...
随机推荐
- 暑假集训test-8-28
大概是从我一年以来做过的最傻逼的一套题了.. 一个半小时打完三个程序三个暴力拍完以为自己AK了,开心地耍了两个小时. 结果T3要写高精,LL炸了后4个点,中间还有个点是啥都不选的,我没用0去更新又炸了 ...
- 移动端多选插件-jquery
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- map和unordered_map使用小结
map和unordered_map unordered_map简介: #include <cstdio> #include <iostream> #include <un ...
- python从入门到大神---Python的jieba模块简介
python从入门到大神---Python的jieba模块简介 一.总结 一句话总结: jieba包是分词技术,也就是将一句话分成多个词,有多种分词模型可选 1.分词模块包一般有哪些分词模式(比如py ...
- 暴力”注入Explorer
暴力"注入Explorer pjf(jfpan20000@sina.com) 向一个运行中的进程注入自己的代码,最自然莫过于使用Cr ...
- 关于double的输入输出
double定义的变量输入的时候一定要%lf输入,要是%f输入的话,得到的结果会是0 float输入的时候是%f 但是在输出的时候%lf和%f都可以输出 建议使用double类型时,用%lf输入,%f ...
- postman中如何传数组
方法一: postman的传参: java接收: package com.nps.base.xue.xd.groovyEngine import com.google.gson.Gson import ...
- 读取.properties配置文件(转载)
读取.properties 文件 配置文件的一种,内容以键值对的形式存在,且每个键值对独占一行.#号作为行注释的起始标志,中文注释会自动进行unicode编码.示例: # ip and port of ...
- 003-JavaString数据类型
String类型可以和8中基本数据类型做运算(byte/short/char/int/long/float/double/boolean),且只能是连接运算 1. 区分 连接符 和 “+” 的区别 c ...
- go 简介与包
简介 Go语言是一种新的语言,一种并发的.带垃圾回收的.快速编译的语言.它具有以下特点: 1.它可以在一台计算机上用几秒钟的时间编译一个大型的Go程序. 2.Go语言为软件构造提供了一种模型,它使依赖 ...