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 ...
随机推荐
- 利用STM32CubeMX之SPI
现在我们继续使用STM32CubeMX来生成SPI工程.我们的硬件平台还是我们熟悉的STM32F103C8开发板. 设置时钟树中的配置 现在打开SPI的设置 如果想修改管脚的名字可以红色框中进行修改, ...
- [转]USB之Part 4 - Protocol
原地址http://www.usbmadesimple.co.uk/ums_4.htm Controlling a Device Before we go into detail, we need t ...
- Oracle 表复杂查询之多表合并查询
转自:https://www.cnblogs.com/GreenLeaves/p/6635887.html 本文使用到的是oracle数据库scott方案所带的表,scott是oracle数据库自带的 ...
- Django之集合函数使用与mysql表的创建特殊字段分析
1. 集合函数的使用场景: -- 单独使用: 不分组, 只查聚合结果 -- 分组使用: 按字段分组, 可查询分组字段与聚合结果 2. 导入聚合函数 from django.db.models impo ...
- 根据svm将视频帧转换为img
# -*- coding: utf-8 -*- """ Created on Mon Oct 1 09:32:37 2018 @author: Manuel " ...
- fb发布打包外部资源
将资源放在src文件夹下面即可 然后在打包那就会看到资源,勾上即可
- Leetcode 题解 Jump Game
一,笨方法 o(n^2).果然看完别人的解法就自惭形秽啊!! 我用的动态规划方法. 比如输入 i: 0 1 2 3 4 ———————————————— a[i]: 2 3 1 0 4 直接利用原来 ...
- Java读写avro例子
一.avro是一个数据序列化框架,可以高效得进行序列化和反序列化,支持C, C++, C#, Java, PHP, Python, 和Ruby语言.现在使用Java来读写. 二.环境搭建 1.下载av ...
- kinematic与static刚体不会触发任何接触回调
Main.as package{ import Box2D.Common.Math.b2Vec2; import Box2D.Dynamics.b2Body; import Box2D.Dynamic ...
- Linux tr命令使用方法
tr命令主要用于删除文件中控制字符或进行字符转换.本文主要介绍tr命令的基本语法和使用实例. tr基本语法 tr命令格式:tr [ -d ] [ -c ] [ -s ] [ 字符串1 ] [ 字符串2 ...