Codeforces Beta Round #1

2023-05-16

做了好久 感觉做的有点蠢 题目总体难度不高吧应该 因为考虑的不周WA了两次 

题目传送门:http://codeforces.com/contest/1

A. Theatre Square
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a.

What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square.

Input

The input contains three positive integer numbers in the first line: n,  m and a (1 ≤  n, m, a ≤ 109).

Output

Write the needed number of flagstones.

Examples
input

6 6 4
  
output

4  

题解:铺地砖嘛就是 用边长a的正方形铺满一个n*m的平面 不能裁割 然后就直接ceil(n/a)*ceil(m/a) 注意下数据范围可能会超出int。。

AC代码:

#include <cstdio>  
#include <cmath>  
typedef long long LL;  
  
int main(){  
    LL n, m, a;  
    scanf("%I64d%I64d%I64d", &n, &m, &a);  
    printf("%I64d\n", LL(ceil(1.0*n/a) * ceil(1.0*m/a)));  
    return 0;  
} 


B. Spreadsheets
time limit per test
10 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. After ZZ there follow three-letter numbers, etc.

The rows are marked by integer numbers starting with 1. The cell name is the concatenation of the column and the row numbers. For example, BC23 is the name for the cell that is in column 55, row 23.

Sometimes another numeration system is used: RXCY, where X and Y are integer numbers, showing the column and the row numbers respectfully. For instance, R23C55 is the cell from the previous example.

Your task is to write a program that reads the given sequence of cell coordinates and produce each item written according to the rules of another numeration system.

Input

The first line of the input contains integer number n (1 ≤ n ≤ 105), the number of coordinates in the test. Then there follow n lines, each of them contains coordinates. All the coordinates are correct, there are no cells with the column and/or the row numbers larger than 106.

Output

Write n lines, each line should contain a cell coordinates in the other numeration system.

Examples
input

2
R23C55
BC23
  
output

BC23
R23C55
  
题解:两种形式的字符转换 一种是R数字C数字 R行C列 一种是字母数字 字母代表列数字代表行 

简单字符串处理 注意点的话一是判断是哪一种格式 因为R23很容易就判断成R23C55的格式了 二是转换的时候关于Z的问题 

AC代码:

#include <bits/stdc++.h>
using namespace std;
const int maxn = 101000;
char col[maxn];
string str;
bool flag;
int len;
int n;

int main() {
    int t;
    cin >> t;
    while(t--) {
        cin >> str;
        len = str.size();
        memset(col, '\0', sizeof(col));
        flag = false;
        if(str[0] == 'R' && (str[1] >= '0' && str[1] <= '9')) {     //判断是哪一种格式的字符串
            for(int i = 2; i < len; ++i) {
                if(str[i] == 'C') {
                    flag = true;
                    break;
                }
            }
        }
        if(flag) {                      //R23C55格式
            int r = 0, c = 0;
            bool mark = true;
            for(int i = 1; i < len; ++i) {
                if(str[i] == 'C') {
                    mark = false;
                    continue;
                }
                if(mark) {
                    r = r * 10 + (str[i] - '0');
                }
                else {
                    c = c * 10 + (str[i] - '0');
                }
            }
            for(int i = 0; ; ++i) {
                if(c == 0) {
                    break;
                }
                int m = c % 26;             //对Z做一个特殊处理
                if(m == 0) {
                    m = 26;
                    c = c / 26 - 1;
                }
                else {
                    c /= 26;
                }
                col[i] = m - 1 + 'A';
            }
            n = strlen(col);
            for(int i = n-1; i >= 0; --i) {
                cout << col[i];
            }
            cout << r << endl;
        }
        else {                  //BC55格式
            bool mark = true;
            int r = 0, c = 0;
            for(int i = 0; i < len; ++i) {
                if(str[i] >= '0' && str[i] <= '9') {
                    mark = false;
                }
                if(mark) {
                    col[i] = str[i];
                }
                else {
                    r = r * 10 + (str[i] - '0');
                }
            }
            n = strlen(col);
            for(int i = 0; i < n; ++i) {
                c = c * 26 + (col[i] - 'A' + 1);
            }

            cout << 'R' << r << 'C' << c << endl;
        }
    }
    return 0;
}


C. Ancient Berland Circus
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.

In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from one circus to another. In each corner of the arena there was a special pillar, and the rope strung between the pillars marked the arena edges.

Recently the scientists from Berland have discovered the remains of the ancient circus arena. They found only three pillars, the others were destroyed by the time.

You are given the coordinates of these three pillars. Find out what is the smallest area that the arena could have.

Input

The input file consists of three lines, each of them contains a pair of numbers –– coordinates of the pillar. Any coordinate doesn't exceed 1000 by absolute value, and is given with at most six digits after decimal point.

Output

Output the smallest possible area of the ancient arena. This number should be accurate to at least 6 digits after the decimal point. It's guaranteed that the number of angles in the optimal polygon is not larger than 100.

Examples
input

0.000000 0.000000
1.000000 1.000000
0.000000 1.000000
  
output

1.00000000
  
题解:有一个圆形的斗兽场 圆上有X个木柱 刚好能构成一个正多边形 但是有三个木柱不见了

现在给三个木柱的坐标 判断这个舞台的最小面积 数组合法 绝对能组成三角形 不会大于100边型

海伦公式求出外接圆半径

R= a * b * c / (4 * S)

S= sqrt(p * (p - a) * (p - b) * (p - c))

p = (a + b + c) / 2

余弦定理求三个角

angle = acos(1 - edge * edge / (2 * R * R))

fgcd求三个角最大公约数 就是正多边形分解的n个小三角形两条半径的边夹角

因为是正多边形 所以只要求出一条边与两个半径围成的面积*N就是多边形的面积

最后正弦定理求面积 

S = R * R * sin(angle) / 2 * (2 * pi / angle)

AC代码:

#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);                           //PI

double diameter(double a, double b, double c);          //海伦公式
double fgcd(double a, double b);                        //最大公约数

int main() {
    double x[3], y[3];
    double edge[3];
    for(int i = 0; i < 3; ++i) {
        scanf("%lf%lf", &x[i], &y[i]);
    }
    for(int i = 0; i < 3; ++i) {            //求三条边长
        edge[i] = sqrt((x[i] - x[(i+1) % 3]) * (x[i] - x[(i+1) % 3]) + (y[i] - y[(i+1) % 3]) * (y[i] - y[(i+1) % 3]));
    }

    double r = diameter(edge[0], edge[1], edge[2]);     //海伦公式求半径
    double angle[3];
    for(int i = 0; i < 2; ++i) {                        //三个圆心角
        angle[i] = acos(1 - edge[i] * edge[i] / (2 * r * r));
    }
    angle[2] = 2 * pi - angle[0] - angle[1];
    double angle_fgcd = fgcd(angle[0], fgcd(angle[1], angle[2]));           //三个圆心角的最大公约数
    double s = pi / angle_fgcd * r * r * sin(angle_fgcd);                   //求面积
    printf("%.6f\n", s);
    return 0;
}

double diameter(double a, double b, double c) {
    double p = (a + b + c) / 2;
    double s = sqrt(p * (p - a) * (p - b) * (p - c));
    return a * b * c / (4 * s);
}

double fgcd(double a, double b){
    if(fabs(a - 0) < 1e-2) {
        return b;
    }
    if(fabs(b - 0) < 1e-2) {
        return a;
    }
    return fgcd(b, fmod(a, b));
}




本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Codeforces Beta Round #1 的相关文章

  • [codeforces 1409B] Minimum Product 让两数的差距越大越好

    Codeforces Round 667 Div 3 参与排名人数12482 codeforces 1409B Minimum Product 让两数的差距越大越好 总目录详见https blog csdn net mrcrack arti
  • C. Doremy‘s IQ(二分/贪心)

    题目 题意 给定n个任务和艾米的智商q 艾米要按顺序处理这n个任务 每个任务有难度值a i 对于每个任务 艾米可以选择处理 也可以选择不处理 如果艾米当前的智商q大于等于任务a i 则艾米可以直接处理该任务 智商不受任何影响 如果艾米当前的
  • 1400*A. World Football Cup(模拟)

    Problem 19A Codeforces 解析 模拟 记录总得分 净胜球 进球数 坑点 其中注意净胜球是进球数的差 己方进球数 对手进球数 可以为负数 排序即可 include
  • 1600*D. Constructing the Array(优先队列

    解析 每次找到最长的连续0序列 取其中点置为 i 优先队列维护 优先按照长度排序 相同则按照下标左优先排序 include
  • codeforces Gym 101341 K Competitions

    Problem codeforces com gym 101341 problem K vjudge net contest 162325 problem K Meaning 有 n 场比赛 每一场有 开始时间 a 结束时间 b 价值 c
  • 1200*A. You‘re Given a String...(枚举)

    include
  • 动态动态规划(DDP)

    1 Problem E Codeforces 一 题目大意 给你一个无向图 第i和i 1条边的权值是w i 问你每个点不在自己原本的点的代价是多少 会有q组询问 表示修改第i条边的权值 二 解题思路 可以观察到 完成这个操作需要每条边经过两
  • Daniel and Spring Cleaning【数位DP】【Codeforces 1245 F】

    Codeforces Round 597 Div 2 F 这道题化简一下就是让我们求有上下限的2进制数中有几对满足每一位的相 值不为1的对数 那么 首先看到这个1e9就会让人想到数位DP 然后接着就是如何去求的这样一个问题 我们不如将上下限
  • Matlab 如何生成一个[a,b]范围内随机整数的2种方法【已经解决】

    如何使用MATLAB生成一个 a b 范围内的随机整数 比如 随机生成 9 13 范围内的一个 或多个 整数 首先感谢 slandarer的指正 现已经更改 round 为四舍五入取整 而非向上取整 方法1为一个较为不错的方法 方法1 ra
  • Codeforces Round#808 div.1+div.2题解

    视频讲解 BV1ya411S7KF div 2 A Difference Operations 题目大意 给定长度为 n n n 的数组 a a a 可以进行任意次操作 每次操作选择一个整数
  • 1400*C. No Prime Differences(找规律&数学)

    解析 由于 1 不是质数 所以我们令每一行的数都相差 1 对于行间 分为 n m之中有存在偶数和都为奇数两种情况 如果n m存在偶数 假设m为偶数 如果都为奇数 则 include
  • 1600*C. Slava and tanks(思维)

    解析 如果n为奇数 则偶数位为奇数位少 1 则先轰炸偶数位 再轰炸奇数位 再一次轰炸偶数位 如果n为偶数 则任意顺序 于是无论奇偶 全部按照 偶 奇 偶 轰炸 则总次数为 n n 2 下取整 include
  • Codeforces Round #561 (Div. 2)ABC

    三个题 各位大佬别喷我 我很菜 A Silent Classroom There are n students in the first grade of Nlogonia high school The principal wishes
  • Educational Codeforces Round 149 (Rated for Div. 2)A~D

    Grasshopper on a Line 题意 给出n和k 求从0到n最少走几步 以及步长 要求步长不能整除k 思路 从n往下找到 k不等于0的数 输出该数和n 该数即可 如果n k 0 那就只需要一步 代码 gt File Name a
  • Codeforces 1475C. Ball in Berland(二元容斥)

    题目传送门 题意 一个班级有a个男生和b个女生 现在这个班级有k对男女愿意一起出席毕业典礼 这里注意k对男女中可能会有某个男生或女生出现在多个pair中 你从这k对中找出两对 使得这两对中的男生不相同 女生不相同 即一个男生或女生不可能在一
  • beta 二项式和 beta 分布的 alpha 和 beta 估计

    我正在尝试将我的数据拟合到 beta 二项式分布并估计 alpha 和 beta 形状参数 对于此分布 先验取自 beta 分布 Python 没有 beta 二项式的拟合函数 但有 beta python beta 拟合和 R beta
  • 4 年每日数据的滚动回归,每个新回归和不同因变量提前一个月

    我有 5 个自变量 附加数据中的 B F 列 和一些因变量 附加数据中的 G M 列 我需要针对所有自变量对每个因变量进行多重回归 回归必须有 4 年的数据窗口 并且每个新的估计都必须提前一个月 我需要提取系数并对每个系数进行 vasice
  • Google Play 中的生产版和测试版

    我已在 Google Play 中以生产模式发布了一个应用程序 现在 我有一个新版本 我想以 Beta 模式为有限数量的私人 Beta 用户发布 有可能两者兼得吗 即生产模式下的版本 1 0 和测试模式下的版本 1 1 或者我应该维护一个不
  • microsoft graph rest api beta:由azure ad b2c中的api创建的应用程序无效

    我正在尝试按照以下文档使用 beta api 创建广告应用程序 可以在 Azure AD B2C 中成功创建应用程序 notAzure Active Directory 符合预期 问题是当我尝试从门户打开此应用程序时 页面只是不断加载 而应
  • 无法在 xcode 8 beta 6 上编译 AWS CustomIdentityProvider

    我在 iOS 应用程序中使用 Amazon Cognito 和 Facebook 登录 直到 beta 5 为止此代码从这个SO线程 https stackoverflow com questions 37597388 aws cognit

随机推荐

  • VTK 3D图像显示

    目的 根据不同需求 xff0c 医学3D图像的显示方式有多种 xff0c 本篇先简单罗列3D图像的几种显示模式 xff0c 后续再进行详细补充 1 剂量模体和二维数据 体模原图 xff08 网络截图 xff09 xff1a 体模二维X射线影
  • 原版win7全新安装后无法通过windows update安装更新的解决办法.2023-03-07

    首先要确保网络畅通 系统时间设置正确 系统没有被病毒流氓程序等破坏 是一个正常完整的初始安装的系统 方法一 1 安装 Windows 更新客户端 kb3138612 kb3138612 Microsoft Update Catalog 2
  • xmind 8 pro Mac破解版(思维导图) 附xmind 8 序列号

    链接 https pan baidu com s 1tTKYuqCjGo WC2ns6tN54w 密码 1b1w 转载地址 小伙伴们XMind 8 pro Mac破解版 思维导图 最新版本v3 7 8中文破解版上线了 xff0c 本次的XM
  • 操作系统系列笔记(五) - 同步互斥, 信号量和管程

    同步互斥 背景 并发进程在多个进程间有资源共享 导致执行过程是不确定性和不可重现的 程序错误可能是间歇性发生 原子操作 是指一次不存在任何中断或失败的操作 操作系统需要利用同步机制 在并发执行的同时保证一些操作是原子操作 几个状态 互斥 一
  • compilation terminated. The terminal process terminated with exit code: 1头文件包含错误解决办法

    错误描述 xff1a d coding clanguage datastruct chapterone mian1 cpp 1 46 fatal error c1 h No such file or directory include 34
  • 实践支持HTTPS SSL的七牛云存储CDN

    最近 xff0c 听说七牛云存储CDN这货支持HTTPS SSL Godaddy SSL证书 xff0c 试用了一下 xff0c 简直发现了新大陆 刚开始设置好以后 xff0c 发现HTTPS下的网页并没有采用七牛的服务 xff0c 只是H
  • 超详细,多图,PVE安装以及简单设置教程(个人记录)

    前言 写这个的目的是因为本人健忘所以做个记录以便日后再折腾时查阅 本人笔拙如有选词 xff0c 错字 xff0c 语法 xff0c 标点错误请忽视 xff0c 大概率知道了也不会修改 xff0c 本人能看懂就好 内容仅适用于本人的使用环境
  • Visual Studio 编译时moc 某些头文件找不到,编译不过,解决办法

    Visual Studio 编译时moc 某些头文件找不到 xff0c 编译不过 xff0c 解决办法 主要是不同的VS版本提交时存在的差异造成的 需要把编译时moc不过的头文件先移除掉 xff0c 然后再添加回来 xff0c 再编译就能编
  • UITableViewController使用

    列表视图控制器 xff0c 用起来很方便 xff0c 不仅可以实现分组列表 xff0c 连tem都有很多定义好的样式 xff0c 使用时基本上不需要有大的自定义的部分 xff0c 这里做一些简单的尝试 1 新建MyTableViewCont
  • TQ2440外接GPIO蜂鸣器驱动程序

    本文通过TQ2440开发板上可外接的GPIO口GPG14连接蜂鸣器 xff0c 通过控制GPG14引脚的高低电平的输出和高低电平输出之间的时间间隔来使蜂鸣器发出不同的声音 1 打开S3C2440的底板原理图找到GPIO xff0c 如下图所
  • Ubuntu下QT静态编译教程

    1 安装Ubuntu系统 xff0c 然后 root 账户登录 xff0c 不然可能会有权限问题 xff0c 避免麻烦 2 打开终端 xff0c 安装必要环境 xff1a 注 xff1a 如安装时 xff0c 遇到暂停需要输入y时 xff0
  • 用 GitHub Actions 自动打包发布 Python 项目

    用 GitHub Actions 自动打包发布 Python 项目 文章目录 用 GitHub Actions 自动打包发布 Python 项目前言在 GitHub 上保存 token创建 workflow定义工作流程的工作环境签出项目 x
  • 用 R 做数据分析

    用 R 做数据分析 Vol 0 xff1a 数据的数字特征及相关分析 导入数据 导入文本表格数据 Year Nationwide Rural Urban 1978 184 138 405 1979 207 158 434 1980 236
  • win下配置Rust及Clion开发环境

    登录官网下载最新的win安装包 地址 默认情况下 rustup安装在用户目录下 也就是C盘 这里我们通过修改环境变量的方式 安装到D盘 RUSTUP HOME 存储工具链和配置文件CARGO HOME 存储cargo的缓存 一定要在rust
  • [docker]CentOS安装docker

    文章目录 先卸载旧版本添加 Docker 软件源使用dnf安装使用yun安装 配置镜像源加速关于tencentOS系统的差异处理 先卸载旧版本 span class token function sudo span yum remove s
  • c语言printf输出格式

    最近C语言中遇到一些基础知识 xff0c 写出来分享一下 xff1a 一 一些基本输出格式小试 include lt stdio h gt include lt stdlib h gt int main int x 61 017 print
  • Linux man命令解析

    文章目录 使用方法手册页面结构手册章节说明命令选项命令参数常见用法1 man k command2 man f command man命令 英文单词manual 使用手册 的缩写 是Linux系统中的一个命令 用于显示其他命令的手册页面 它
  • Linux usr/share/doc帮助文档介绍

    文章目录 usr share doc介绍目录结构查看文档使用文档总结附录 xff1a 关于删除 usr share doc的影响 usr share doc 介绍 在Linux系统中 usr share doc目录是非常重要的 它是用来存储
  • POJ题目分类 很好很有层次感

    OJ上的一些水题 可用来练手和增加自信 poj3299 poj2159 poj2739 poj1083 poj2262 poj1503 poj3006 poj2255 poj3094 初期 一 基本算法 1 枚举 poj1753 poj29
  • Codeforces Beta Round #1

    做了好久 感觉做的有点蠢 题目总体难度不高吧应该 因为考虑的不周WA了两次 题目传送门 xff1a http codeforces com contest 1 A Theatre Square time limit per test 1 s