题目链接:  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. 使用 IntelliTrace 调试应用程序

    IntelliTrace 如何能够大幅改善您的日常开发活动,并提升您快速轻松诊断问题的能力,而不必重新启动应用程序和使用传统的“中断-单步执行-检查”技术进行调试.介绍了组织如何能够通过在测试过程中收 ...

  2. python学习 day2 (3月2日)

    .if if else 和 if elif else 的区别是: 前者 判断第一个 判断完第二个 之后还会执行else: 后者是只有满足条件(即都不符合if.elif里的条件时才会进入else) 不清 ...

  3. kbmmw 5.04 发布

    增加了一大波功能,消灭了一大堆问题,也肯定引进了一大票BUG.We are happy to announce the release of our latest version of kbmMW. ...

  4. centos7 sqoop 1 搭建笔记

    1.require : java环境,hadoop,hive ,mysql2.下载解压sqoop13.设置环境变量 export SQOOP_HOME=/data/spark/bin/sqoop ex ...

  5. org.jsoup.HttpStatusException: HTTP error fetching URL. Status=403

    爬取网站的时候 conn = Jsoup.connect(url).timeout(5000).get();直接用get方法,有些网站可以正常爬取. 但是有些网站报403错误,403是一种在网站访问的 ...

  6. swift-基础语法2

    一.整形 :有符号和无符号类型 有符号类型:Int ,Int8 ,Int32,Int64 无符号类型: UInt ,UInt8 UInt32,UInt64 注意点:如果你的开发环境是32位,那么Int ...

  7. layer 弹框不显示内容

    // layer的弹框不显示信息 可能是背景颜色和字体颜色冲突 改下字体颜色即可 layer.msg('<p style="color:black">用户名不能为空&l ...

  8. Python-IDLE实现清屏

    1.将下面文件复制到命名为ClearWindow.py的文件下,移动到 …Python\Python36-32\Lib\idlelib下. ############################## ...

  9. VSCode 设置侧边栏字体大小;Visual Studio Code改变侧边栏大小

    1.代码改写,进入默认安装的如下路径 C:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out ...

  10. typecho 调用评论最多热门文章

    在当前主题的functions.php文件中添加以下函数代码: function getHotComments($limit = 10){ $db = Typecho_Db::get(); $resu ...