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})\),速度完全相等时不可能相交,不完全相等时,若能相交,则有:

\[x_1 + v_{x_1}t = x_2 + v_{x_2}t
\]

\[y_1 + v_{y_1}t = y_2 + v_{y_2}t
\]

联立可得:

\[\frac{x_1 - x_2}{v_{x_2} - v_{x_1}} = \frac{y_1 - y_2}{v_{y_2} - v_{y_1}}$$ ①
两点式:
$$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的更多相关文章

  1. Codeforces Round #539 div2

    Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...

  2. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

  3. Codeforces Round#320 Div2 解题报告

    Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...

  4. Codeforces Round #564(div2)

    Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...

  5. Codeforces Round #361 div2

    ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...

  6. Codeforces Round #626 Div2 D,E

    比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...

  7. CodeForces Round 192 Div2

    This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...

  8. Codeforces Round #359 div2

    Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...

  9. Codeforces Round #360 div2

    Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...

随机推荐

  1. JsJquery小技巧

    JS对URL编码 :encodeURI() .Net对URL解码:HttpUtility.UrlDecode() 格式化输出百分数 function formatePercent(data){     ...

  2. Java-Class-@I:org.junit.Test

    ylbtech-Java-Class-@I:org.junit.Test 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部 1. package org.junit; import ...

  3. 完美解决 IE6 position:fixed 固定定位问题

    关于 position:fixed; 属性 生成绝对定位的元素,相对于浏览器窗口进行定位. 元素的位置通过 “left”, “top”, “right” 以及 “bottom” 属性进行规定. pos ...

  4. PAT L2-021. 点赞狂魔 /// sort+unique去重

    https://www.patest.cn/contests/gplt/L2-021 题目大意: 微博上有个“点赞”功能,你可以为你喜欢的博文点个赞表示支持.每篇博文都有一些刻画其特性的标签,而你点赞 ...

  5. websokect的原理

    WebSocket 机制 以下简要介绍一下WebSocket的原理及运行机制. WebSocket是HTML5下一种新的协议.它实现了浏览器与服务器全双工通信,能更好的节省服务器资源和带宽并达到实时通 ...

  6. iOS开发系列-常见离线存储方式

    概述 在很多社交App手机在手机没有网络时,重新启动应用,依然能否展示上次访问的数据,提高用户体验,这个就是离线数据存储的运用场景.在iOS开发中常见的离线存储技术有Plist存储.个人偏好存储.解归 ...

  7. Unity开发一些实用的提高效率的技巧

    该文章参考总结自Unity微信官方 原文: Unity小技巧介绍 1 如果编辑器意外崩溃了,但场景未保存,这时可以打开工程目录,找到/Temp/_Backupscenes/文件夹,可以看到有后缀名为. ...

  8. Java迷宫代码,广度优先遍历,最短路径

    使用一个队列,采用层层扩张的方式,寻找迷宫最优的路径信息,再用一个迷宫节点数组记录行走信息方向常量定义: public interface Constant { // 右方向 int RIGHT = ...

  9. (依赖注入框架:Ninject ) 一 手写依赖注入

    什么是依赖注入? 这里有一个场景:战士拿着刀去战斗: 刀: class Sword { public void Hit(string target) { Console.WriteLine($&quo ...

  10. Arthas 3.1.2 版本发布 | 增加 logger/heapdump/vmoption 命令

    最近偶尔有用户反馈某些 HTTP 接口出现超时问题,而 web 服务端的 Trace 监控没有出现 http 返回值为 503 等异常情况.出现这种情况一般是web容器出现问题,客户端连 Arthas ...