Codeforces Round #198 (Div. 2)

昨天看到奋斗群的群赛,好奇的去做了一下,

大概花了3个小时Ak,我大概可以退役了吧

那下面来稍微总结一下

A. The Wall

Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on.

Iahub has the following scheme of painting: he skips x - 1 consecutive bricks, then he paints the x-th one. That is, he'll paint bricks x, 2·x, 3·x and so on red. Similarly, Floyd skips y - 1 consecutive bricks, then he paints the y-th one. Hence he'll paint bricks y, 2·y, 3·y and so on pink.

After painting the wall all day, the boys observed that some bricks are painted both red and pink. Iahub has a lucky number a and Floyd has a lucky number b. Boys wonder how many bricks numbered no less than a and no greater than b are painted both red and pink. This is exactly your task: compute and print the answer to the question.

input
2 3 6 18
output
3
Note

Let's look at the bricks from a to b (a = 6, b = 18). The bricks colored in red are numbered 6, 8, 10, 12, 14, 16, 18. The bricks colored in pink are numbered 6, 9, 12, 15, 18. The bricks colored in both red and pink are numbered with 6, 12 and 18.

一句话题意:给你a,b,n,m,求在[n,m](闭区间)内有多少个数可以同时整除a和b

很显然非常清真的一道A题,题意很明晰,

求出a,b的最小公倍数,然后求出n以内和m以内各有几个,

最后相减,注意因为是闭区间,所以要特判n是否符合

#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,n,m;
scanf("%d%d%d%d",&a,&b,&n,&m);
int lcs=a/__gcd(a,b)*b,ans1=n/lcs,ans2=m/lcs;
if (n%lcs==) ans1--;
printf("%d",ans2-ans1);
}

B. Maximal Area Quadrilateral

Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one which has all four vertices in the set of special points. Given the set of special points, please calculate the maximal area of a special quadrilateral.

input
5
0 0
0 4
4 0
4 4
2 3
output
16.000000
Note

In the test example we can choose first 4 points to be the vertices of the quadrilateral. They form a square by side 4, so the area is 4·4 = 16.

一句话题意:给你n个点,让你选出四个点,使得这四个点组成的四边形面积最大

感觉这道题其实有D题的难度,可参见考试时A掉人数:A>D>C>B>E

首先我们可以把一个四边形分成两个三角形来求

这样那我们可以O(n^2)枚举对角线,然后就可以求出上三角形的最大值和下三角形的最大值

我们就可以得出最大的四边形的面积,

求三角形面积可以用叉积,这样,就可以得到了O(n^3)的了

***如果不会叉积的,极力推荐去学习一下计算几何初步

#include <cstdio>
#include <complex>
#include <algorithm>
using namespace std;
typedef complex<int> xint;
const int inf=;
xint point[];
int crs(xint a,xint b){
return (a.real()*b.imag()-a.imag()*b.real());
} int main(){
int n,s=; scanf("%d",&n);
for (int i=,x,y;i<n&&==scanf("%d %d",&x,&y);++i)
point[i]=xint(x,y);
for (int i=;i<n;++i)
for (int j=i+;j<n;++j){
int a=inf,b=-inf;
for (int k=;k<n;++k){
int c=crs(point[k]-point[i],point[j]-point[i]);
if(c<) a=min(a,c); else if(c>) b=max(b,c);
if(a<&&b>) s=max(s,b-a);
}
}
printf("%.8lf\n",s/2.0);
}

Codeforces Round #198 (Div. 2)A,B题解的更多相关文章

  1. Codeforces Round #198 (Div. 2)C,D题解

    接着是C,D的题解 C. Tourist Problem Iahub is a big fan of tourists. He wants to become a tourist himself, s ...

  2. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  3. Codeforces Round #672 (Div. 2) A - C1题解

    [Codeforces Round #672 (Div. 2) A - C1 ] 题目链接# A. Cubes Sorting 思路: " If Wheatley needs more th ...

  4. Codeforces Round #198 (Div. 2)E题解

    E. Iahub and Permutations Iahub is so happy about inventing bubble sort graphs that he's staying all ...

  5. Codeforces Round #198 (Div. 2) E. Iahub and Permutations —— 容斥原理

    题目链接:http://codeforces.com/contest/340/problem/E E. Iahub and Permutations time limit per test 1 sec ...

  6. Codeforces Round #614 (Div. 2) A-E简要题解

    链接:https://codeforces.com/contest/1293 A. ConneR and the A.R.C. Markland-N 题意:略 思路:上下枚举1000次扫一遍,比较一下 ...

  7. Codeforces Round #610 (Div. 2) A-E简要题解

    contest链接: https://codeforces.com/contest/1282 A. Temporarily unavailable 题意: 给一个区间L,R通有网络,有个点x,在x+r ...

  8. Codeforces Round #611 (Div. 3) A-F简要题解

    contest链接:https://codeforces.com/contest/1283 A. Minutes Before the New Year 题意:给一个当前时间,输出离第二天差多少分钟 ...

  9. Codeforces Round #198 (Div. 1) D. Iahub and Xors 二维树状数组*

    D. Iahub and Xors   Iahub does not like background stories, so he'll tell you exactly what this prob ...

随机推荐

  1. CNN结构:用于检测的CNN结构进化-一站式方法

    有兴趣查看原文:YOLO详解 人眼能够快速的检测和识别视野内的物体,基于Maar的视觉理论,视觉先识别出局部显著性的区块比如边缘和角点,然后综合这些信息完成整体描述,人眼逆向工程最相像的是DPM模型. ...

  2. .NET Core & EntityFrameworkCore

    前言 .NET Core 相比于 .NET Fromework 有跨平台.轻量化且开源的优势. 在使用 EntityFrameworkCore 的时候也遇到了很多问题,至于网络上的教程嘛...大部分都 ...

  3. 【剑指Offer】52、正则表达式匹配

      题目描述:   请实现一个函数用来匹配包括'.'和'*'的正则表达式.模式中的字符'.'表示任意一个字符,而'*'表示它前面的字符可以出现任意次(包含0次). 在本题中,匹配是指字符串的所有字符匹 ...

  4. 定位IO瓶颈的方法,iowait低,IO就没有到瓶颈?

    通过分析mpstat的iowait和iostat的util%,判断IO瓶颈 IO瓶颈往往是我们可能会忽略的地方(我们常会看top.free.netstat等等,但经常会忽略IO的负载情况),今天给大家 ...

  5. 【JavaScript框架封装】使用原生js封装的类似于JQuery的框架及核心源码分享(多文件版本)

    这个版本的JQuery是对上一个版本的JQuery,使用了require.js进行了二次封装,基本上把前面的每一个框架封装成为一个单独的模块,最终的目录结构如下: 由于代码量和目录比较多,这个封装好的 ...

  6. [POI2012]OKR-A Horrible Poem

    正解:对于一个区间l,r,它的循环节长度一定是它的因数. 然后如果循环节是这个长度,那么[l+len,r]一定等于[l,r-len]. 然后每次询问的时候就把它的长度的最小质因子提出来. BZOJ上都 ...

  7. vue监听页面大小变化重新刷新布局

    在项目中由于某些div元素在布局的时候需要初始化宽高,因为当浏览器缩小屏幕的时候需要重新刷新页面视图. 分析思路: 1.在store中创建state,用于保存当前浏览器的宽.高值. 2.在mounte ...

  8. android 权限问题分析

    Android系统是运行在Linux内核上的,Android与Linux分别有自己的一套严格的安全及权限机制, 很多像我这样的新手,尤其是习惯了windows低安全限制的用户,很容易在这方面弄混淆,下 ...

  9. String去除重复字符两个方法

    package cn.aresoft; import java.util.ArrayList;import java.util.List; public class TestBasic { publi ...

  10. Codeforces 919D Substring (拓扑图DP)

    手动博客搬家: 本文发表于20180716 10:53:12, 原地址https://blog.csdn.net/suncongbo/article/details/81061500 给定一个\(n\ ...