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 ...
随机推荐
- jq动画分析
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- java web项目使用IDEA打成war包
步骤: 1.点击 File -->Project Structure...如下图: 2.出现如下界面后点击 Artifacts--> 绿色加号-->Web Application:A ...
- js 滑动门的实现
原理:滑动门,这里以图片进行实例,首先设定主盒子div的宽度和高度设定,并进行图片初始化位置的设定,然后将图片绑定事件,并设定要达到的效果 html代码: <!DOCTYPE html> ...
- 2:if 语句
if 语句 语法形式: 第一种,只有两个分支: if 表达式: something else: something 第二种,有多个分支: if 表达式1: do something 1 elif 表达 ...
- linux 3.10的list_del
最近看到一个page的数据比较奇怪: crash> page ffffea002c239c58 struct page { flags = , _count = { counter = 34-- ...
- ReactiveX 学习笔记(8)错误处理和 To 操作符
Error Handling Operators Operators to Convert Observables 本文的主题为对 Observable 进行错误处理的操作符以及转换 Observab ...
- js 监听浏览器刷新还是关闭事件 - 转
监听页面关闭: window.onbeforeunload = function() { //鼠标相对于用户屏幕的水平位置 - 窗口左上角相对于屏幕左上角的水平位置 = 鼠标在当前窗口上的水平位置 v ...
- 11.枚举类.md
目录 1.定义: 2.枚举类和普通类的区别: 2.1枚举类的简单构建: 2.2枚举类的成员变量.方法和构造 2.3实现接口的枚举类 1.定义: 2.枚举类和普通类的区别: 枚举类的默认修饰符是 pub ...
- python __dict__
dict 以key-value 的形式存储着本对类/模块的: 模块的__dict__ 属性: 存储了模块的 name (这个也是模块的一个单独的键,即:在Bx.py 中引入Ax.py 那么,在Bx中, ...
- Hibernate 再接触 核心开发接口
1.可以重载方法进行配置文件的指定 sessionFactory = new AnnotationConfiguration().configure("hibernate.xml" ...