Codeforces Beta Round #27 (Codeforces format, Div. 2)
Codeforces Beta Round #27 (Codeforces format, Div. 2)
http://codeforces.com/contest/27
A
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int a[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
for(int i=;i<=n;i++){
cin>>a[i];
}
sort(a+,a+n+);
int i;
for(i=;i<=n;i++){
if(a[i]!=i){
cout<<i<<endl;
break;
}
}
if(i==n+) cout<<n+<<endl;
}
B
找出度数大的那个点
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int book[][];
int n;
int d[]; void Check(int &x,int &y){
for(int i=;i<=n;i++){
for(int j=;j<=n;j++){
if(i==j) continue;
if(!book[i][j]){
x=i,y=j;
return;
}
}
}
} int main(){
#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
int nn=n*(n-)/-;
int u,v;
for(int i=;i<=nn;i++){
cin>>u>>v;
book[u][v]=book[v][u]=;
d[u]++;
}
int x,y;
Check(x,y);
if(d[x]>d[y]){
cout<<x<<" "<<y<<endl;
}
else{
cout<<y<<" "<<x<<endl;
}
}
C
模拟
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int a[];
int n; int Check(){
int flag=;
for(int i=;i<n;i++){///<<<<<<
if(a[i]>a[i+1]){
flag=;
}
}
if(flag==){
return ;
}
flag=;
for(int i=;i<n;i++){///>>>>>>
if(a[i]<a[i+]){
flag=;
}
}
if(flag==) return ;
return -;
} struct sair{
int v,pos;
}b[];
int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
int co=;
for(int i=;i<=n;i++){
cin>>a[i];
if(a[i]!=a[i-]){
b[co].v=a[i];
b[co].pos=i;
co++;
}
}
co--;
int flag=Check();
if(flag==||flag==){
cout<<<<endl;
}
else{
cout<<<<endl; for(int i=;i<co;i++){
if(b[i-].v>b[i].v&&b[i].v<b[i+].v){
cout<<b[i-].pos<<" "<<b[i].pos<<" "<<b[i+].pos<<endl;
break;
}
if(b[i-].v<b[i].v&&b[i].v>b[i+].v){
cout<<b[i-].pos<<" "<<b[i].pos<<" "<<b[i+].pos<<endl;
break;
}
}
}
}
D
用类似二分染色的思想,把交叉的道路染成不同的颜色,如果判断的时候出现交叉的道路有相同的颜色,就输出Impossible
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ vector<int>ve[];
int n,m;
int s[],t[];
int vis[];
int col[]; void dfs(int pos,int c){
if(vis[pos]) return;
vis[pos]=;
col[pos]=c;
for(int i=;i<ve[pos].size();i++){
dfs(ve[pos][i],c^);
if(col[pos]==col[ve[pos][i]]){
cout<<"Impossible"<<endl;
exit();
}
}
} int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=;i<=m;i++){
cin>>s[i]>>t[i];
if(s[i]>t[i]) swap(s[i],t[i]);
}
for(int i=;i<=m;i++){
for(int j=;j<=m;j++){
if(s[i]<s[j]&&t[i]<t[j]&&s[j]<t[i]){
ve[i].pb(j);
ve[j].pb(i);
}
}
}
for(int i=;i<=m;i++){
dfs(i,);
}
for(int i=;i<=m;i++){
if(col[i]) cout<<'i';
else cout<<'o';
}
}
E
知识点:反素数
参考博客:https://www.cnblogs.com/handsomecui/p/5017484.html
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int prim[]={,,,,,,,,,,,,,,,};
int n;
ull ans=-; void dfs(int pos,ull v,int num){
if(num==n&&ans>v) ans=v;
for(int i=;i<=;i++){
if(num*(i+)>n||v*prim[pos]>ans) break;
v*=prim[pos];
dfs(pos+,v,num*(i+));
}
} int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
dfs(,,);
cout<<ans<<endl;
}
Codeforces Beta Round #27 (Codeforces format, Div. 2)的更多相关文章
- Codeforces Beta Round #27 (Codeforces format, Div. 2) E. Number With The Given Amount Of Divisors 反素数
E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 ...
- Codeforces Beta Round #27 E. Number With The Given Amount Of Divisors 含n个约数最小数
http://codeforces.com/problemset/problem/27/E RT,求含n个约数的最小的数 我们设答案p = 2^t1 * 3^t2 * -- * p^tk(其中p是第k ...
- Codeforces Beta Round #32 (Div. 2, Codeforces format)
Codeforces Beta Round #32 (Div. 2, Codeforces format) http://codeforces.com/contest/32 A #include< ...
- Codeforces Beta Round #31 (Div. 2, Codeforces format)
Codeforces Beta Round #31 (Div. 2, Codeforces format) http://codeforces.com/contest/31 A #include< ...
- Codeforces Beta Round #29 (Div. 2, Codeforces format)
Codeforces Beta Round #29 (Div. 2, Codeforces format) http://codeforces.com/contest/29 A #include< ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
随机推荐
- js 监听组合键盘事件
有些时候,我们需要在网页上,增加一些快捷按键,方便用户使用一些常用的操作,比如:保存,撤销,复制.粘贴等等. 我们所熟悉的按键有这么集中类型: 单独的按键操作,如:delete.up.down等 两位 ...
- springboot 端口号
1. 读取端口号 2.多端口运行 2.
- VC中链接错误,提示string重定义
VC链接错误,说是string已经有了实现了,只要 rebuild 一下好了. Linking...LINK : warning LNK4075: ignoring '/EDITANDCONTINUE ...
- element(vue.js)+django 整合
近期开始接触Python,从web开发入门.尝试Django与vue整合,大概分3个阶段: 1.基于Django开发web后端 2.基于element开发好前端 3.前后端整合 参考:https:// ...
- jqGrid基本使用
jqGrid: 参照网址:官网地址http://www.trirand.com/ http://blog.mn886.net/jqGrid/(快速获取demo) http://www.guriddo. ...
- Spring Cloud限流详解
转自:https://blog.csdn.net/tracy38/article/details/78685707 在高并发的应用中,限流往往是一个绕不开的话题.本文详细探讨在Spring Cloud ...
- 【转】解决Eclipse中SVN版本信息不显示的问题
eclipse 中使用 svn 插件,原本正常,未作任何更改,最近几天突然eclipse 中查看文件时,文件后面的 版本号 . 文件的状态图标 等等都不见了.以为有插件冲突,卸载了好多其他的相关的插件 ...
- org.hibernate.AssertionFailure: null id in xxx.xx.xx的问题
今日在开发时遇到一个比较奇怪的问题,保存时报这个异常: org.hibernate.AssertionFailure: null id in com.aa.TShoucang null id,这个是什 ...
- Constructor构造方法
我们写一个car类,并写一个无参构造方法. public class Car { int speed; //构造方法名字和 类一致 区分大小写 不需要写返回值 和参数列表 public Car(){ ...
- 使用django实现自定义用户认证
参考资料:https://docs.djangoproject.com/en/1.10/topics/auth/customizing/ 直接拉到最后看栗子啦 django自定义用户认证(使用自 ...