Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined)
传送门: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)的更多相关文章
- Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题
Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题 [Problem Description] 总共两次询 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- 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 ...
- 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 ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
- 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 < ...
- Educational Codeforces Round 48 (Rated for Div. 2) CD题解
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...
随机推荐
- schemaeasyui实例:SSh结合Easyui实现Datagrid的分页显示
查了好多资料,发现还是不全,干脆自己整理吧,最少保证在我的做法正确的,以免误导读者,也是给自己做个记载吧! 克日学习Easyui,发现非常好用,界面很雅观.将学习的心得在此写下,这篇博客写SSh结合E ...
- 理解git分支-远程分支
远程分支 远程引用是对远程仓库的引用(指针),包括分支.标签等等. 你可以通过 git ls-remote (remote)来显式地获得远程引用的完整列表,或者通过 git remote show ( ...
- [ios-必看] WWDC 2013 Session笔记 - iOS7中的多任务【转】
感谢:http://onevcat.com/2013/08/ios7-background-multitask/ http://www.objc.io/issue-5/multitasking.htm ...
- Excel单元格所在的行和列变色
网友问到如何通过移动光标选择单元格,所在的行和列变色.如每次输入价格的时候,想想在横竖方向上有颜色标识,这样方便对照输入价格 . 这里可以使用窗体的Worksheet_SelectionChange ...
- CodeForces 721D Maxim and Array
贪心,优先队列. 先看一下输入的数组乘积是正的还是负的. ①如果是负的,也就是接下来的操作肯定是让正的加大,负的减小.每次寻找一个绝对值最小的数操作就可以了. ②如果是正的,也是考虑绝对值,先操作绝对 ...
- Largest prime factor
problem 3:Largest prime factor 题意:求600851475143的最大的质因数 代码如下: #ifndef PRO3_H_INCLUDED #define PRO3_H_ ...
- 利用Hibernate监听器实现用户操作日志
网上搜索发现,实现用户操作日志的方式有:自定义注解方式.Hibernate拦截器方式.Hibernate监听器方式等. 1.自定义注解方式较为麻烦,需要进行操作记录的方法均需要添加注解,但是相对的操作 ...
- 创建maven多模块项目(idea工具)
1.创建父项目模块(new 一个maven空项目模块)不勾选 create from archetype 删除src目录 2.创建子模块 webapp (该模块为web入口模块) 3.创建其他子模块 ...
- CSS3 filter(滤镜) 属性
filter 属性定义了元素(通常是<img>)的可视效果 语法: object.style.WebkitFilter="grayscale(100%)" 小栗子: 修 ...
- MIT线性代数课程 总结与理解-第一部分
概述 个人认为线性代数从三个角度,或者说三个工具来阐述了线性关系,分别是: 向量 矩阵 空间 这三个工具有各自的一套方法,而彼此之间又存在这密切的联系,通过这些抽象出来的工具可以用来干一些实际的活,最 ...