题目链接:  http://codeforces.com/contest/977  

A. Wrong Subtraction

题意

给定一个数x,求n次操作输出。操作规则:10的倍数则除10,否则减1

直接写,手速题,没啥好说的

B. Two-gram

题意

求出现次数最多的连续两个字符

还是签到题,我居然很麻烦地用了map,= =算了,思路畅通都无所谓了

#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<map>
using namespace std;
int main()
{
char a[],s[],ss[];
int n;
while(cin>>n)
{
cin>>a;
map<string,int>mp;
int MAX=-;
for(int i=;i<strlen(a)-;i++)
{
s[]=a[i]; s[]=a[i+];
mp[s]++;
//cout<<s<<endl;
if(mp[s]>MAX) MAX=mp[s],ss[]=a[i],ss[]=a[i+];
}
cout<<ss[]<<ss[]<<endl;
}
return ;
}

C. Less or Equal

题意

给一串数组,是否找到一个数x,找到k个数字<=x,找到输出x,不能输出-1。

第二组,要找到两个数字,排序后出现1,3,3,会出现三个数字小于等于3,所以不能找到。

注意下k==0的时候就好了,没啥好说的

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#define ll long long
using namespace std;
const int maxn=2e5+;
int a[maxn];
int main()
{
int m,k;
while(cin>>m>>k)
{
for(int i=;i<m;i++)
cin>>a[i];
sort(a,a+m);
if(k==)
{
if(a[]==) puts("-1");
else cout<<a[]-<<endl;
}
else if(k==m) cout<<a[k-]<<endl;
else
{
if(a[k-]==a[k]) puts("-1");
else cout<<a[k-]<<endl;
}
}
return ;
}

D. Divide by three, multiply by two

题意

直接看样例吧  4 8 6 3 12 9  把这个序列排成一个这样的序列, 前一位是后一位数的一半或者3倍,所以排序后是这样 9 3 6 12 4 8

dfs或者直接双重for循环都可以,不过赛后看到个数学思路的题解,觉得很有灵性= =

直接按对3有更多约数的多少来排(前一位是后一位的3倍),有相同个则从小到大(也就是前一位是后一位数的一半)

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#define ll long long
using namespace std;
const int maxm=2e5+;
const int maxn=1e5+; ll a[];
ll s(ll num)
{
ll cnt=;
while(num%==)
{
cnt++;
num/=;
}
return cnt;
}
bool cmp(ll x,ll y)
{
if(s(x)!=s(y))
return s(x)>s(y);
else return x<y;
}
int main()
{
int n;
while(cin>>n)
{
for(int i=;i<n;i++)
cin>>a[i];
sort(a,a+n,cmp);
for(int i=;i<n;i++)
printf("%lld%c",a[i],i==n-?'\n':' ');
}
}

E. Cyclic Components

题意

给定点的个数和各条边,问有多少个环

既然是环,一个点就会对应两次啊,直接并查集啊,巴拉巴拉,水水水就过去了

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#define ll long long
using namespace std;
const int maxn=2e5+;
int pre[maxn],edg[maxn],cnt;
struct node
{
int u,v;
}a[maxn];
void iint()
{
for(int i=;i<maxn;i++) pre[i]=i;
}
int ffind(int x)
{
if(x==pre[x]) return x;
return pre[x]=ffind(pre[x]);
}
void join(int x,int y)
{
x=ffind(x),y=ffind(y);
if(x!=y) pre[x]=y;
else cnt++;
}
int main()
{
int m,n;
while(cin>>m>>n)
{
iint();
memset(edg,,sizeof(edg));
for(int i=;i<n;i++)
{
cin>>a[i].u>>a[i].v;
edg[a[i].u]++;
edg[a[i].v]++;
}
cnt=;
for(int i=;i<m;i++)
{
if(edg[a[i].u]==&&edg[a[i].v]==)
join(a[i].u,a[i].v);
}
cout<<cnt<<endl;
}
return ;
}

F. Consecutive Subsequence

题意

给你一个数组找出最长的递增子序列的长度以及下标位置。

例如:  第一组样例 3 3 4 7 5 6 8

    最长的子序列为3 4 5 6,长度为4。

    下标为1 3 5 6或2 3 5 6

觉得dp才是正解,贴个别人的http://www.bubuko.com/infodetail-2595514.html

可是比赛时候不知道为什么被我map玄学给过了2333

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#define ll long long
using namespace std;
const int maxn=2e5+;
int a[maxn];
int main()
{
ios::sync_with_stdio(false);
int n,tmp;
while(cin>>n)
{
map<int,int>mp;
int max_pos=-,Max=-;
for(int i=;i<=n;i++)
{
cin>>a[i];
mp[a[i]]=mp[a[i]-]+;
if(mp[a[i]]>Max) Max=mp[a[i]],tmp=a[i],max_pos=i;
}
int u=tmp-Max+;
cout<<Max<<endl;
bool f=true;
for(int i=;i<=max_pos;i++)
{
if(a[i]==u)
{
if(f) cout<<i,f=false;
else cout<<" "<<i;
u++;
}
}
cout<<endl;
}
return ;
}

Codeforces Round #479 (Div. 3)解题报告的更多相关文章

  1. Codeforces Round #324 (Div. 2)解题报告

    ---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...

  2. Codeforces Round #382 (Div. 2) 解题报告

    CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...

  3. Codeforces Round #274 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/479 这次自己又仅仅能做出4道题来. A题:Expression 水题. 枚举六种情况求最大值就可以. 代码例如以下: #inc ...

  4. Codeforces Round #380 (Div. 2) 解题报告

    第一次全程参加的CF比赛(虽然过了D题之后就开始干别的去了),人生第一次codeforces上分--(或许之前的比赛如果都参加全程也不会那么惨吧),终于回到了specialist的行列,感动~.虽然最 ...

  5. Codeforces Round #216 (Div. 2)解题报告

    又范低级错误! 只做了两题!一道还被HACK了,囧! A:看了很久!应该是到语文题: 代码:#include<iostream> #include<];    ,m2=;    ;i ...

  6. Codeforces Round #281 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/493 A题 写完后就交了,然后WA了,又读了一遍题,没找出错误后就开始搞B题了,后来回头重做的时候才发现,球员被红牌罚下场后还可 ...

  7. Codeforces Round #277 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/486 A题.Calculating Function 奇偶性判断,简单推导公式. #include<cstdio> ...

  8. Codeforces Round #276 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/485 A题.Factory 模拟.判断是否出现循环,如果出现,肯定不可能. 代码: #include<cstdio> ...

  9. Codeforces Round #350 (Div. 2)解题报告

    codeforces 670A. Holidays 题目链接: http://codeforces.com/contest/670/problem/A 题意: A. Holidays On the p ...

随机推荐

  1. ssh安装

    http://blog.chinaunix.net/uid-20791108-id-3761681.htmlhttp://www.cnblogs.com/mliudong/p/4094519.html ...

  2. PHP字符串替换函数

    str_replace函数 描述:实现字符串替换,区分大小写 语法:mixed str_replace(mixed $search, mixed replace, mixed $subject, [i ...

  3. Scrapy框架爬虫

    一.sprapy爬虫框架 pip install pypiwin32 1) 创建爬虫框架 scrapy startproject Project # 创建爬虫项目 You can start your ...

  4. day06作业---字典循环

    '''1.1使⽤循环打印以下效果: ***************''' for a in range(1,6): print(a*'*') '''1.2: ***** **** *** ** * ' ...

  5. android开发笔记(2)

    我之前完成了SDK的安装,这次需要在eclipse中导入相关的控件. 一.下载ADT 在之前下载的网站上下载相关的ADT的压缩包. 二.在eclipse中进行导入 在eclipse中的Help-> ...

  6. 链栈的基本操作(C语言)

    栈的链式储存结构称为链栈.链栈的节点类型与链式线性表的节点类型 定义相同,不同的是它是仅在表头进行操作的单链表.链栈通常用不带头节 点的单链表来实现,栈顶指针就是链表的头指针 ,如图所示: 代码如下: ...

  7. 686. Repeated String Match

    方法一.算是暴力解法吧,拼一段找一下 static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); cl ...

  8. 2018.12.31 bzoj4001: [TJOI2015]概率论(生成函数)

    传送门 生成函数好题. 题意简述:求nnn个点的树的叶子数期望值. 思路: 考虑fnf_nfn​表示nnn个节点的树的数量. 所以有递推式f0=1,fn=∑i=0n−1fifn−1−i(n>0) ...

  9. vue属性值调方法

    <td>{{showPrice(product.sellprice)}}</td>

  10. mac os下 android studio真机调试

    http://www.cnblogs.com/developer-wang/p/6719555.html 如果没有 .bash_profile 只需要创建 .bash_profile,然后增加andr ...