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;
}

转载于:https://www.cnblogs.com/huibixiaoxing/p/9018238.html

Codeforces Round #478 Div2 975A 975B 975C 975D相关推荐

  1. codeforces Round#429 (Div2)

    2017-08-20 10:00:37 writer:pprp 用头文件#include <bits/stdc++.h>很方便 A. Generous Kefa codeforces 84 ...

  2. Codeforces Round#310 div2

    C题:这题说的是套娃,如果做题的时候知道是套娃,那就好理解多了 规则1:套娃A可以放到套娃B里面,当且仅当套娃B没有放在其他套娃里面 规则2:套娃A放在套娃B里面,且套娃B没有放在其他套娃里面,那么可 ...

  3. Codeforces Round #359 div2

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

  4. Codeforces Round 361 div2

    雪崩,全错掉了GG.前两道题相对之前的难度大一点啊,不过A题有个循环应该是从0开始而不是1开始这样的低级错误不应该犯.B题差不多是一个BFS,但是我当时始终绕着最短路径写来写去,一直各种TLE与WA. ...

  5. Codeforces Round #360(div2)

    考完试的晚上,打了场codeforces,主要感觉由于睡眠不够,最后差了点劲啊,C题基本上都过了,但忙中出错最后把数组调小易于debug后再提交又忘记改回来了,看到Runtime Error自己竟没反 ...

  6. codeforces round 416 div2补题

    第一题,水题 A. Vladik and Courtes #include<bits/stdc++.h> using namespace std; int main() {long lon ...

  7. codeforces round 421 div2 补题 CF 820 A-E

    A Mister B and Book Reading  O(n)暴力即可 #include<bits/stdc++.h> using namespace std; typedef lon ...

  8. codeforces round #576 div2 D Welfare State(线段树)[单点修改+区间修改]

    题意:有一些数字,以及一些操作.操作一是单点修改,输入1 b c,将位置b改成c,操作二是输入2 a,将不大于a的数全部改成a.求更改完毕后的数. tag的运用:tag是对被覆盖区间上加一个标记,那么 ...

  9. codeforces round 418 div2 补题 CF 814 A-E

    A An abandoned sentiment from past 水题 #include<bits/stdc++.h>using namespace std;int a[300],b[ ...

  10. Codeforces Round #267 Div2 C George and Job --DP

    题意:把长度为n的序列分成k个m长的连续小序列,这些连续小序列的和最大是多少. 解法:显然DP. 定义: dp[i][j] 为前 i 个元素分成j个m端,且 i 是第j个的末尾的最大和. 那么有: d ...

最新文章

  1. JavaWeb--过滤器
  2. Java Swing编程之仿js树状折叠菜单
  3. Android小数和整数相互转换
  4. java se/ee_嗨,您好 。 。 ! 您如何评价Java / Java EE技能?
  5. PoE交换机如何才能稳定连接和安全使用?
  6. SpringMVC 集成 mybatisPlus
  7. 抓住那只喵(HTML5-神经猫)
  8. for相关 java_用java编写一个程序,求2到100之间的偶数和(使用for循环)
  9. 网页编辑PHP变量,编辑文件中的php代码和变量
  10. 兄弟j220怎么清零_兄弟Brother全系列打印机清零大全
  11. Unity3D人工智能学习笔记
  12. linux虚拟机界面菜单栏和任务栏不见了,已解决
  13. Java常用命令:jps、jstack、jmap、jstat(带有实例教程)
  14. Butterfly美化
  15. 支持向量机(股票)——Python量化
  16. HYSBZ - 2818 Gcd —— 莫比乌斯反演
  17. safari 浏览器输入框不能输入
  18. 清华北大计算所自动化所计算机夏令营详细攻略
  19. 五粮液:绩优蓝筹稳步填权
  20. 英语学习时间:《新概念英语第二册》Lesson 1 笔记

热门文章

  1. 02-Go语言数据类型与变量
  2. Go语言 关于go error处理风格的一些讨论和个人观点(上)
  3. jquery基础研究学习【基础】
  4. SimpleDateFormat关于时间类的一些常用处理
  5. openstack nova调用libvirt,跟踪libvirt源码实例详解(cpu_mode及live_migrate 错误解决)...
  6. uva 1045(二分图最大权匹配)
  7. python处理pdf文件_python处理操作pdf全攻略
  8. 复制粘贴之后出现问号怎么办_网页没办法复制粘贴?老司机传授这3招太赞了,全网任意免费复制...
  9. JVM学习04-垃圾回收概念与算法
  10. ribbon基于接口配置超时_Spring Cloud第二篇:服务消费者RestTemplate+Ribbon