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出现了两次. 方法:比较无脑 ...
随机推荐
- 从头开始学Android之(一)——— Android架构
从事Android开发已经两年多了,最近项目上特别清闲,刚开始时在闲暇的时候都不知道干嘛,整天混日子.有一天突然有个以前同学找到我,说要我帮忙做一个Android的需求,就是在后台截屏(涉及到服务以及 ...
- Win7查看本地是否安装JDK及安装路径的方法
工具/原料 win7 方法/步骤 1 开始->点击运行,输入:cmd 2 然后在命令提示符中,输入:java -version 假如看到有版本提示那么安装成功 3 假如忘记了java ...
- 分析PMT changed for the ROM:it must be downloaded.升级失败。
应用场景描写叙述: 同样项目不同版本号(不同分支),使用Smart Phone Flash Tool工具交叉升级,出现PMT changed for the ROM;it must be downlo ...
- [RxJS] Implement RxJS `concatMap` by Waiting for Inner Subscriptions to Complete
Unlike mergeMap and switchMap, concatMap focuses on when "inner" subscriptions "compl ...
- Android自带的分享功能案例
MainActivity的代码 package com.hpsvse.weiboshare; import java.io.File; import android.net.Uri; import a ...
- ImageViewCoverflow
https://github.com/Bertlk/ImageViewCoverflow https://github.com/dolphinwang/ImageCoverFlow http://ww ...
- Nginx系列三 内存池的设计
Nginx的高性能的是用非常多细节来保证,epoll下的多路io异步通知.阶段细分化的异步事件驱动,那么在内存管理这一块也是用了非常大心血.上一篇我们讲到了slab分配器,我们能够能够看到那是对共享内 ...
- S2SH的集成(Struts2,Spring,Hibernate)----青软S2SH(笔记)
- Tomcat最多支持并发多少用户?
当一个进程有 500 个线程在跑的话,那性能已经是很低很低了.Tomcat 默认配置的最大请求数是 150,也就是说同时支持 150 个并发,当然了,也可以将其改大.当某个应用拥有 250 个以上并发 ...
- HTTP要点概述:四,HTTP方法
使用HTTP协议的时候,客户端可以通过HTTP方法告知服务器自己请求的意图. 看了这篇文章以后,谁再说HTTP方法只有GET和POST,你的眼睛是用来吃饭的嘛! 一,GET:获取资源 GET用来请求访 ...