Codeforces Round #479 (Div. 3)解题代码
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
while(k--)
{
int tmp=n%10;
if(tmp==0)
n/=10;
else n-=1;
}
cout<<n<<endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1000;
char ch[MAXN];
int cnt[MAXN];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>ch[i];
}
for(int i=1;i<=n-1;i++)
{
for(int j=i+1;j<=n-1;j++)
{
if(ch[i]==ch[j]&&ch[i+1]==ch[j+1])
cnt[i]++;
}
}
int index;
int maxnCnt=-1;
for(int i=1;i<=n-1;i++)
{
if(maxnCnt<cnt[i])index=i,maxnCnt=cnt[i];
}
cout<<ch[index]<<ch[index+1]<<endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200005;
int a[MAXN];
int main()
{
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
if(k==0)
{
if(a[0]>1)cout<<a[0]-1<<endl;
else cout<<-1<<endl;
}
else
{
int tmp=a[k-1];
int cnt=0,flag=0;
for(int i=0;i<n;i++)
{
if(tmp>=a[i])
{
cnt++;
}
else break;
}
if(cnt>k)cout<<-1<<endl;
else cout<<tmp<<endl;
}
return 0;
}
D. Divide by three, multiply by two
#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int MAXN=120;
struct node
{
LL x,y;
}a[MAXN];
bool cmp(const node x1,const node x2)
{
if(x1.y!=x2.y)return x1.y>x2.y;
else return x1.x<x2.x;
}
LL cnt(LL x)
{
int cnt3=0;
while(x%3==0)
{
cnt3++;
x/=3;
}
return cnt3;
}
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i].x;a[i].y=cnt(a[i].x);
}
sort(a,a+n,cmp);
for(int i=0;i<n;i++)
cout<<a[i].x<<" ";
cout<<endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200005;
vector<int>G[MAXN];
bool vis[MAXN]
bool f;
void dfs(int v)
{
vis[v]=1;
if(G[v].size()!=2)
f=1;
for(auto x: G[v])
{
if(!vis[x])
dfs(x);
}
}
int main()
{
int n,m,u,v;
cin>>n>>m;
for(int i=0;i<m;i++)
{
cin>>u>>v;
u--,v--;
G[u].push_back(v);
G[v].push_back(u);
}
int ans=0;
f=0;
for(int i=0;i<n;i++)
{
if(!vis[i])
{
f=0;
dfs(i);
ans+=(!f);
}
}
cout<<ans<<endl;
return 0;
}
Codeforces Round #479 (Div. 3)解题代码的更多相关文章
- Codeforces Round #479 (Div. 3)解题报告
题目链接: http://codeforces.com/contest/977 A. Wrong Subtraction 题意 给定一个数x,求n次操作输出.操作规则:10的倍数则除10,否则减1 直 ...
- Codeforces Round #324 (Div. 2)解题报告
---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...
- Codeforces Round #274 (Div. 2) 解题报告
题目地址:http://codeforces.com/contest/479 这次自己又仅仅能做出4道题来. A题:Expression 水题. 枚举六种情况求最大值就可以. 代码例如以下: #inc ...
- Codeforces Round #380 (Div. 2) 解题报告
第一次全程参加的CF比赛(虽然过了D题之后就开始干别的去了),人生第一次codeforces上分--(或许之前的比赛如果都参加全程也不会那么惨吧),终于回到了specialist的行列,感动~.虽然最 ...
- Codeforces Round #216 (Div. 2)解题报告
又范低级错误! 只做了两题!一道还被HACK了,囧! A:看了很久!应该是到语文题: 代码:#include<iostream> #include<]; ,m2=; ;i ...
- Codeforces Round #276 (Div. 2) 解题报告
题目地址:http://codeforces.com/contest/485 A题.Factory 模拟.判断是否出现循环,如果出现,肯定不可能. 代码: #include<cstdio> ...
- Codeforces Round #350 (Div. 2)解题报告
codeforces 670A. Holidays 题目链接: http://codeforces.com/contest/670/problem/A 题意: A. Holidays On the p ...
- Codeforces Round #271 (Div. 2) 解题报告
题目地址:http://codeforces.com/contest/474 A题:Keyboard 模拟水题. 代码例如以下: #include <iostream> #include ...
- Codeforces Round #479 (Div. 3) B. Two-gram
原题代码:http://codeforces.com/contest/977/problem/B 题解:有n个字符组成的字符串,输出出现次数两个字符组合.例如第二组样例ZZ出现了两次. 方法:比较无脑 ...
随机推荐
- CentOS 7下安装Logstash ELK Stack 日志管理系统(下)
修改防火墙,对外开放tcp/5601 [root@elk elk]# firewall-cmd --permanent --add-port=5601/tcpSuccess[root@elk elk] ...
- #define中的#和##作用
#define语句中的#是把参数字符串化,##是连接两个参数成为一个整体. #define FACTORY_REF(name) { #name, Make##name } 中#name就是将传入的na ...
- C#使用SharpZipLib压缩解压文件
#region 加压解压方法 /// <summary> /// 功能:压缩文件(暂时只压缩文件夹下一级目录中的文件,文件夹及其子级被忽略) /// </summary> // ...
- linux输入yum后提示: -bash: /usr/bin/yum: No such file or directory的解决方案
linux输入yum后提示: -bash: /usr/bin/yum: No such file or directory的解决方案 今天在安装程序时,发现有一个插件未安装,我就随手敲了一个命令,看都 ...
- Win7下安装iMac系统
首先是灰常激动啊,一下午的努力最终在自己华硕的笔记本上安装了mac系统. 先上一个成果截图 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveXl4aGh4/ ...
- Latex 1: 解决latex中遇到一个常见错误:"Improper alphabetic constant."
1.问题: 本人是在WIN7下用texlive 2016,编辑器用的是WinEdt 10.1 ,运行如下代码: \documentclass{ctexbook} \begin{document} \t ...
- Dynamics CRM 修改Excel 最大导出记录限制及 最大上传文件限制
CRM默认的Excel最大导出记录是10000条,最大上传文件限制为5m. 这样的限制可以满足少量数据的批量更新,但是如果数据量比较大的话需要修改最大的导出记录限制,和上传文件的大小,网上有的是直接修 ...
- Eclipse 插件管理
查看已安装的插件: [help]⇒ [About Eclipse]⇒ [Installed Softwares] 1. 常用插件 maven:安装步骤如下: [help]⇒ [Install new ...
- 性能-发挥ORACLE分区表
ORACLE分区表发挥性能 http://www.cnblogs.com/zwl715/p/3962837.html 1.1 分区表PARTITION table 在ORACLE里如果遇到特别大的表, ...
- vs2008添加消息函数方法
开发MFC时,开发工具VS2008不能像开发工具VC++6.0那样,直接在类文件上右击选择“Add Window Message Handles”来添加消息映射.对于我这个初学者,刚开始一直没找到可以 ...