A题求给出映射的反射,水题

#include <cstdio>
int x,ans[105],n;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&x);
ans[x]=i;
}for(int i=1;i<=n;i++)printf("%d ",ans[i]);
return 0;
}

B题,三进制的减法

#include <cstdio>
#include <algorithm>
using namespace std;
int a[1000],b[1000],c[1000];
int A,B,C,la,lb,lc;
int main(){
scanf("%d%d",&A,&C);
while(A){a[la++]=A%3;A/=3;}
while(C){c[lc++]=C%3;C/=3;}
for(int i=0;i<la||i<lc;i++){
if(a[i]==c[i])b[i]=0;
if((a[i]+1)%3==c[i])b[i]=1;
if((a[i]+2)%3==c[i])b[i]=2;
}for(int i=max(la,lc);i>=0;i--)B=B*3+b[i];
printf("%d\n",B);
return 0;
} 

C题题意,更改一个数字,使得数列总和最小

#include <cstdio>
#include <algorithm>
using namespace std;
int n,a[100005];
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++)scanf("%d",&a[i]);
sort(a,a+n);
if(a[n-1]==1)a[n-1]=2;else a[n-1]=1;
sort(a,a+n);
for(int i=0;i<n;i++)printf("%d ",a[i]);
return 0;
}

D题给出八个点,判断是否能够分成两组,使得第一组四点构成正方形,第二组四点构成矩形

构成矩形的判断方式是,对角线长度相等,并且中点重合,构成正方形的判断方式是已构成的矩形相邻两边长度相等

对于八个点利用状态压缩枚举每一种四个点的选择情况,判断是否满足条件即可

#include <cstdio>
#include <algorithm>
using namespace std;
struct data{double x,y;}p[8],p1[4],p2[4];
bool cmp(data a,data b){return a.x==b.x?a.y<b.y:a.x<b.x;}
bool CheckSquare(){
sort(p1,p1+4,cmp);
double d1=(p1[3].x-p1[0].x)*(p1[3].x-p1[0].x)+(p1[3].y-p1[0].y)*(p1[3].y-p1[0].y);
double d2=(p1[2].x-p1[1].x)*(p1[2].x-p1[1].x)+(p1[2].y-p1[1].y)*(p1[2].y-p1[1].y);
return(d1==d2&&(p1[3].x+p1[0].x==p1[1].x+p1[2].x)&&(p1[3].y+p1[0].y==p1[1].y+p1[2].y));
}
bool CheckRectangle(){
sort(p2,p2+4,cmp);
double d1=(p2[3].x-p2[0].x)*(p2[3].x-p2[0].x)+(p2[3].y-p2[0].y)*(p2[3].y-p2[0].y);
double d2=(p2[2].x-p2[1].x)*(p2[2].x-p2[1].x)+(p2[2].y-p2[1].y)*(p2[2].y-p2[1].y);
double d3=(p2[2].x-p2[0].x)*(p2[2].x-p2[0].x)+(p2[2].y-p2[0].y)*(p2[2].y-p2[0].y);
double d4=(p2[0].x-p2[1].x)*(p2[0].x-p2[1].x)+(p2[0].y-p2[1].y)*(p2[0].y-p2[1].y);
return(d1==d2&&d3==d4&&(p2[3].x+p2[0].x==p2[1].x+p2[2].x)&&(p2[3].y+p2[0].y==p2[1].y+p2[2].y));
}
int main(){
for(int i=0;i<8;i++)scanf("%lf%lf",&p[i].x,&p[i].y);
for(int i=0;i<256;i++){
int tmp=i,cnt=0;
for(int j=0;j<8;j++)if((1<<j)&i)cnt++;
if(cnt!=4)continue; cnt=0;int cnt0=0;
for(int j=0;j<8;j++){
if((1<<j)&i)p1[cnt++]=p[j];
else p2[cnt0++]=p[j];
}
if(CheckSquare()&&CheckRectangle()){
puts("YES");
for(int j=0;j<8;j++)if(!((1<<j)&i))printf("%d ",j+1);puts("");
for(int j=0;j<8;j++)if(((1<<j)&i))printf("%d ",j+1);puts("");
return 0;
}
}puts("NO");
return 0;
}

E题的意思是有两个人,分别轮流去除字符串中的一个字符,一个为了让字符串变小,一个为了让字符串变大,问最后的结果的可能性

分类讨论题:

#include<bits/stdc++.h>
using namespace std;
int flag[4],x,y,z,len;
char s[100005];
bool check01(){
if(s[len-1]=='0')return 0;
x=1,y=0,z=0;
for(int i=0;i<len-1;i++){
if(s[i]=='1')x++;
if(s[i]=='0')y++;
if(s[i]=='?')z++;
}if(x-(z+y)>=2||y-(x+z)>=1)return 0;
return 1;
}
bool check10(){
if(s[len-1]=='1')return 0;
x=0,y=1,z=0;
for(int i=0;i<len-1;i++){
if(s[i]=='1')x++;
if(s[i]=='0')y++;
if(s[i]=='?')z++;
}if(x-(z+y)>=2||y-(x+z)>=1)return 0;
return 1;
}
int main(){
scanf("%s",s);
len=strlen(s);
for(int i=0;i<len;i++){
if(s[i]=='1')x++;
if(s[i]=='0')y++;
if(s[i]=='?')z++;
}if(x+z-y>=2)flag[0]=1;
if(y+z-x>=1)flag[1]=1;
if(check01())flag[2]=1;
if(check10())flag[3]=1;
if(flag[1])printf("00\n");
if(flag[2])printf("01\n");
if(flag[3])printf("10\n");
if(flag[0])printf("11\n");
return 0;
}

  

Codeforces Beta Round #97 (Div. 2)的更多相关文章

  1. Codeforces Beta Round #97 (Div. 1) C. Zero-One 数学

    C. Zero-One 题目连接: http://codeforces.com/contest/135/problem/C Description Little Petya very much lik ...

  2. Codeforces Beta Round #97 (Div. 1) B. Rectangle and Square 暴力

    B. Rectangle and Square 题目连接: http://codeforces.com/contest/135/problem/B Description Little Petya v ...

  3. Codeforces Beta Round #97 (Div. 1) A. Replacement 水题

    A. Replacement 题目连接: http://codeforces.com/contest/135/problem/A Description Little Petya very much ...

  4. Codeforces Beta Round #97 (Div. 1)

    B 判矩阵的时候 出了点错 根据点积判垂直 叉积判平行 面积不能为0 #include <iostream> #include<cstdio> #include<cstr ...

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

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

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

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

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

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

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

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

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

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

随机推荐

  1. Activity四种launchMode

    更多内容在这里查看 https://ahangchen.gitbooks.io/windy-afternoon/content/ 总共有四篇关于Activity,task,launchMode的文章, ...

  2. N沟道增强型MOS管双向低频开关电路

    MOS-N 场效应管 双向电平转换电路 -- 适用于低频信号电平转换的简单应用 如上图所示,是 MOS-N 场效应管 双向电平转换电路.双向传输原理: 为了方便讲述,定义 3.3V 为 A 端,5.0 ...

  3. 两个DIV,左DIV宽度固定,右DIV自动填满剩余空间

    <style type="text/css"> #main{ width:98%; } #sidebar{ float:left; width:200px; backg ...

  4. hdu 1210_(逻辑训练)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1210 #include<stdio.h> int main() { int n,t,sum ...

  5. Puppet的执行过程

    图1 Puppet工作流程 1. 客户端Puppetd向Master发起认证请求,或使用带签名的证书. 2. Master告诉Client你是合法的. 3. 客户端Puppetd调用Facter,Fa ...

  6. DRP总结

    DRP终于结束了,战线有点长了.记得刚开始听说DRP的时候,感觉这个名词很专业,再加上视频一共有300集,顿时感觉这是一个大项目,很正规.很专业的项目.虽然后来知道DRP知识ERP的一个分支,项目规模 ...

  7. 【转】Loss Function View

    感谢原文作者!原文地址:http://eletva.com/tower/?p=186 一.Loss Function 什么是Loss Function?wiki上有一句解释我觉得很到位,引用一下:Th ...

  8. Labeling Balls(拓扑排序wa)

    Labeling Balls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12466   Accepted: 3576 D ...

  9. Let the Balloon Rise(map)

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  10. jstack命令使用

    概述 jstack可用于导出java运用程序的线程堆栈.其基本使用语法为: jstack [-l] pid -l 选项用于打印锁的额外信息. 使用演示样例 以下这段代码执行之后会出现死锁现象(由于线程 ...