传送门:http://codeforces.com/contest/757

A题题意是给你一个字符串,让你在里面找到"Bulbasaur"这样的单词有多少个,字符串可以重排列。实际上统计下"Bulbasaur"里面的字母数,再用原串的字母数去除一下取最小值就行了。可以直接两个map搞。这题被hack了一次是因为我错误地复制了case1,case1比原串多了个字母b。下次要仔细看清。

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#define X first
#define Y second
#define clr(u,v); memset(u,v,sizeof(u));
#define in() freopen("data","r",stdin);
#define out() freopen("ans","w",stdout);
#define Clear(Q); while (!Q.empty()) Q.pop();
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e5 + ;
const int INF = 0x3f3f3f3f;
char str[maxn];
const char s[] = {"Bulbasaur"};
map<char, int> M, M2;
int main()
{
scanf("%s", str);
int len = strlen(str), lens = strlen(s), ans = INF;
for (int i = ; i < len; i++)
{
M[str[i]]++;
}
for (int i = ; i < lens; i++)
M2[s[i]]++;
for (map<char, int>::iterator it = M2.begin(); it != M2.end(); it++)
{
ans = min(M[it->X] / it->Y, ans);
}
printf("%d\n", ans);
return ;
}

B题题意是给你一个集合,让你找到一个子集,这个子集里面的数字两两的gcd都不为1,求子集元素最多是多少。我的做法是把集合中的数字做下标记,然后用类似线性筛的做法,从素数开始枚举,更新这个素数的倍数被标记过的最大数量,也就是能够放在同一集合的最大数量。还有个坑点是,1要特判,如果有多个1,只能选择其中一个,因为gcd(1,1)==1。如果有多个大于1的数,可以选多个。比如2 2 2 输出 2,因为gcd(2,2)=2。这题还是比较容易想到的,不过我还是犯了细节错误,范围习惯性写出了sqrt(1e5),导致大于sqrt(1e5)的素数没有被枚举到。实在是太粗心了= =。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#define X first
#define Y second
#define clr(u,v); memset(u,v,sizeof(u));
#define in() freopen("data","r",stdin);
#define out() freopen("ans","w",stdout);
#define Clear(Q); while (!Q.empty()) Q.pop();
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e5 + ;
const int INF = 0x3f3f3f3f;
int Hash[maxn];
bool prime[maxn];
int solve()
{
int ans = ;
for (int i = ; i < maxn; i++)
{
int temp = ;
if (!prime[i])
for (int j = i ; j < maxn; j += i)
{
if (Hash[j]) temp += Hash[j];
prime[j] = ;
}
ans = max(ans, temp);
}
return ans;
}
int main()
{
int n, x;
scanf("%d", &n);
if (n == )
{
printf("");
return ;
}
for (int i = ; i < n; i++)
{
scanf("%d", &x);
Hash[x] ++;
}
printf("%d\n", max(, solve()));
return ;
}

C题题意看了好久,最后还是看错了题意,导致无限wa6。题意是有n个道馆,m种精灵。每个道馆有gi只精灵,他们可以相互进化当他们在该道馆的数量相同,且在其他的道馆每个道馆里面的数量都要相同。(ps:全部道馆的两只精灵数量相同未必能进化,必须保证每个子道馆的精灵数量相同)。理解了题意后就很水了。开个vector V[maxn],V[i]表示第i只精灵在哪个道馆出现过,再对V数组排个序(这个cmp看起来有点像字典序的cmp),然后找到重复部分,A(n,n)算一下就行了。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#define X first
#define Y second
#define clr(u,v); memset(u,v,sizeof(u));
#define in() freopen("data","r",stdin);
#define out() freopen("ans","w",stdout);
#define Clear(Q); while (!Q.empty()) Q.pop();
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e6 + ;
const int maxm = 1e6 + ;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + ;
vector <int> G[maxn];
int main()
{
int n, m;
ll ans = ;
scanf("%d%d", &n, &m);
while (n--)
{
int g, x;
scanf("%d", &g);
while (g--)
{
scanf("%d", &x);
G[x].pb(n);
}
}
ll temp = ;
sort(G + , G + m + );
// for (int i = 1; i <= m; i++)
// {
// for (int j = 0; j < G[i].size(); j++)
// printf("%d ", G[i][j]);
// puts("");
// }
for (int i = ; i <= m; i++)
{
if (G[i] == G[i-])
{
temp++;
ans = (ans * temp) % mod;
}
else temp = ;
}
cout << ans << endl;
return ;
}

其他题暂时还不会,总结一下:本来以为这次混合场能够混点分,结果反而掉了八十多分,还是too naive。这场主要是没注意细节,以及题目根本看不懂= =。虽说对英语本来也不感冒,不过以后还是多看看英文题吧,少点用翻译了。END。

2017-01-13 23:42:34

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined)的更多相关文章

  1. Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题

    Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题 [Problem Description] ​ 总共两次询 ...

  2. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  3. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  4. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  5. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  6. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  7. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...

  8. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

  9. Educational Codeforces Round 39 (Rated for Div. 2) G

    Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ...

  10. Educational Codeforces Round 48 (Rated for Div. 2) CD题解

    Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...

随机推荐

  1. [置顶] ROS探索总结(十一)——机器视觉

    机器视觉在计算机时代已经越来越流行,摄像头价格越来越低廉,部分集成深度传感器的混合型传感器也逐渐在研究领域普及,例如微软推出的Kinect,而且与之配套的软件功能十分强大,为开发带来了极大的便利.RO ...

  2. web打印小结

    项目中有个需求是将winform客户端的打印,移到网页上由客户自行打印,打印要求是根据一定的格式实现套打. 当时的解决方案是使用PDF打印: 1. 准备好套打格式的底图: 2.打开底图,将动态内容画到 ...

  3. mybatis判断list为空

    在传入的map或者对象里面存在一个list,此时想要判断list是否为空,可以 <if test="spids.size()>0 " > and SPid not ...

  4. SQL Server存储过程同时返回分页结果集和总数

    前言 好长时间没摸数据库了,周末在家写了个报表的存储过程,一时间对使用存储过程实现分页的同时并计算出记录总数不知道怎么更好的去实现.按照我们正常的业务逻辑,存储过程数据首先是分页,其次接受若干查询条件 ...

  5. svg动画学习

    首先我们定义一块画布,然后在上面画一个圆形. 他看起来应该是这个样子的:(每一个实例我都会附加图片以及demo链接,方便直观的理解与源代码的查看,查看的时候请使用标准浏览器) 点击查看Demo 现在我 ...

  6. USACO 3.4 Raucous Rockers

    Raucous Rockers You just inherited the rights to N (1 <= N <= 20) previously unreleased songs ...

  7. itoa()函数和atoi()函数

     1.int/float to string/array: C语言提供了几个标准库函数,可以将任意类型(整型.长整型.浮点型等)的数字转换为字符串,下面列举了各函数的方法及其说明.● itoa():将 ...

  8. 获取select选中的值

    $("#CalibrationYear option:selected").text();

  9. 集合点(lr_rendezvous)

    含义: 当通过controller虚拟多个用户执行该脚本时,用户的启动或运行都不一定是同时的.集合点是在脚本的某处设置一个标记,当有虚拟用户运行到这个标记时,停下等待,知道所有用户到达这个标记处,再一 ...

  10. hdu 5996 dingyeye loves stone(博弈)

    题目链接:hdu 5996 dingyeye loves stone 题意: 给你一棵树,树的每一个节点有a[i]个石子,每个人可以将这个节点的石子移向它的父亲,如果没有合法操作,那么就算输,现在给你 ...