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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Codeforces Beta Round #32 (Div. 2, Codeforces format)

    Codeforces Beta Round #32 (Div. 2, Codeforces format) http://codeforces.com/contest/32 A #include< ...

  4. Codeforces Beta Round #31 (Div. 2, Codeforces format)

    Codeforces Beta Round #31 (Div. 2, Codeforces format) http://codeforces.com/contest/31 A #include< ...

  5. Codeforces Beta Round #29 (Div. 2, Codeforces format)

    Codeforces Beta Round #29 (Div. 2, Codeforces format) http://codeforces.com/contest/29 A #include< ...

  6. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  7. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  8. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  9. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

随机推荐

  1. js对象引用和赋值

    体验更优排版请移步原文:http://blog.kwin.wang/programming/js-object-reference-assign.html 先看一个简单例子, var obj = { ...

  2. Java快速开发平台,JEECG 3.7.6性能增强版本发布

    JEECG 3.7.6 性能增强版本发布 导读       ⊙Vue SPA单页面应用 ⊙Datagrid标签实现不同风格切换,支持BootstrapTable.EasyUI ⊙灵活通用代码生成器工厂 ...

  3. 小麦成长记-<专业盗图好几年>

    ========================================图片来源朋友圈的朋友~

  4. 5分钟快速打造WebRTC视频聊天<转>

    原文地址: 5分钟快速打造WebRTC视频聊天 百度一下WebRTC,我想也是一堆.本以为用这位朋友( 搭建WebRtc环境 )的SkyRTC-demo 就可以一马平川的实现聊天,结果折腾了半天,文本 ...

  5. 1.ossutil初步使用

    ossutil对应的阿里云参考文档链接地址: https://help.aliyun.com/document_detail/50452.html?spm=a2c4g.11186623.6.1355. ...

  6. Emac

    https://emacs-china.org/ 启动 console模式的emacs,$emacs -nw 学习参考: 1)<21天精通emacs> 2)Emacs常用命令简集. 3)& ...

  7. 趣味编程:静夜思(Python版)

    from itertools import groupby def verticalWriting(txt, offset): l = lambda x: x[0] % offset for (_, ...

  8. PHP脚本不报错的两点原因

    -------------------------------------------------------------------------------------------------- P ...

  9. asp.net 如何判断输入的值 包括 汉字?

    string input = " 里面是不是汉字 ";bool bl= System.Text.RegularExpressions.Regex.IsMatch(input, @& ...

  10. swift和OC中frame的小差异

    //1.0 OC中 CGRect .CGPoint.CGSize 的结构如下: struct CGRect { CGPoint origin; CGSize size; }; struct CGPoi ...