Codeforces Beta Round #1

本文深入探讨了信息技术领域的多个关键方面,从前端开发的HTML、CSS、JavaScript到后端开发的PHP、Java、MySQL,再到移动开发、游戏开发、大数据开发等多个细分领域。通过详细的介绍和案例分析,旨在为读者提供全面的技术视角,帮助理解不同技术之间的联系与应用。同时,文章还涵盖了开发工具、嵌入式硬件、音视频基础、AI音视频处理等热门话题,力求构建一个立体的技术知识体系。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Theatre Square
time limit per test
2 seconds
memory limit per test
64 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.

Sample test(s)
input
6 6 4
output
4

题意:给你一个矩形的常和宽,以及边长为a的正方形砖块,用砖块去铺这个矩形,允许重叠,直接用ceil函数

#include <cstdio>
#include <cmath>
int main()
{
    int m,n,a;
    scanf("%d%d%d",&m,&n,&a);
    printf("%.lf\n",ceil(m*1.0/a)*ceil(n*1.0/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.

Sample test(s)
input
2
R23C55
BC23
output
BC23
R23C55


题意:类似于Excel里面的表示方法,用来转换两种表示方法之间的编码,直接暴力。。。

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <stack>
using namespace std;
char s[20];
bool judge(char s[])
{
    int l=strlen(s);
    int ans=0;
    for(int i=1;i<l;i++)
        if((s[i]>='0'&&s[i]<='9')&&(s[i-1]>='A'&&s[i-1]<='Z'))
            ans++;
    if(ans==2)
        return true;
    return false;
}
int main()
{
    int test;
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    scanf("%d",&test);
    while(test--)
    {
        scanf("%s",s);
        if(judge(s))
        {
            int l=strlen(s);
            int r=0,c=0;
            int rr=1,cc=1;
            int i,j;
            for(i=l-1;i>=0;i--)
            {
                if(s[i]>='A'&&s[i]<='Z')
                    break;
                if(s[i]>='0'&&s[i]<='9')
                {
                    c+=cc*(s[i]-'0');
                    cc*=10;
                }
            }/*
            for(;i>=0;i--)
            {
                if(s[i]>='A'&&s[i]<='Z')
                    continue;
                if(s[i]>='0'&&s[i]<='9')
                    break;
            }
            i++;*/
            for(j=i-1;j>=0;j--)
            {
                if(s[j]>='A'&&s[j]<='Z')
                    break;
                if(s[j]>='0'&&s[j]<='9')
                {
                    r+=rr*(s[j]-'0');
                    rr*=10;
                }
            }
            stack<char>st;
            while(!st.empty())
                st.pop();
            while(c)
            {
                int num=c%26;
                if(num==0)
                {
                    st.push('Z');
                    c--;
                }
                else
                    st.push(num-1+'A');
                c/=26;
            }
            while(!st.empty())
            {
                printf("%c",st.top());
                st.pop();
            }
            printf("%d\n",r);
        }
        else
        {
            int r=0,c=0;
            int rr=1,cc=1;
            int i,j,l=strlen(s);
            stack<char>st;
            stack<char>nt;
            while(!nt.empty())
                nt.pop();
            while(!st.empty())
                st.pop();
            for(i=0;i<l;i++)
            {
                if(s[i]>='0'&&s[i]<='9')
                    break;
                st.push(s[i]);
            }
            for(j=i;j<l;j++)
            {
                nt.push(s[j]);
            }
            while(!st.empty())
            {
                c+=cc*(st.top()-'A'+1);
                cc*=26;
                st.pop();
            }
            while(!nt.empty())
            {
                r+=rr*(nt.top()-'0');
                rr*=10;
                nt.pop();
            }
            printf("R%dC%d\n",r,c);
        }
    }
    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.

Sample test(s)
input
0.000000 0.000000
1.000000 1.000000
0.000000 1.000000
output
1.00000000


题意:给你三个点的坐标,求由这三个点得到的正多边形的面积,由于不知道这个正多边形有多少条边,以及不清楚由这n个等腰三角形的每个三角形的面积,开始我想的方法是求由这三个点组成的三角形的外接圆及半径,然后每条边于外心组成的三角形中圆心角最小的那个三角形对应的那条边应该就是这个正多边形组成的基本元素,然后WA了,原因是(思路错了!)

换种方法做,假使开始是3边形,这种与圆心组成的角中,如果每个角都满足能够满足这些角围成一圈就退出,直到n边形为止,这样一直枚举下去,找到合适的情况就break

// WA 了,思路跪了(感谢woshiren01指出错误)所以跪了
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define PI 3.141592653589793
struct point
{
    double x;
    double y;
};
point ans,p[3];
struct Line
{
    point a;
    point b;
    double distance;
    double jiao;
};
point intersection(Line u,Line v)
{
    point res=u.a;
    double k=((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))/((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x));
    res.x+=(u.b.x-u.a.x)*k;
    res.y+=(u.b.y-u.a.y)*k;
    return res;
}
point circumcenter(point a,point b,point c)
{
    Line u,v;
    u.a.x=(a.x+b.x)/2;
    u.a.y=(a.y+b.y)/2;
    u.b.x=u.a.x-a.y+b.y;
    u.b.y=u.a.y+a.x-b.x;

    v.a.x=(a.x+c.x)/2;
    v.a.y=(a.y+c.y)/2;
    v.b.x=v.a.x-a.y+c.y;
    v.b.y=v.a.y+a.x-c.x;
    return intersection(u,v);
}
bool cmp(Line xx,Line yy)
{
    return xx.jiao>yy.jiao;
}
double dis(point a,point b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double cal(Line ll)
{
    double xx=dis(ll.a,ans);
    double yy=dis(ll.b,ans);
    double zz=ll.distance;
    return (xx*xx+yy*yy-zz*zz)/2/xx/yy;
}
double area(double x0,double y0,double x1,double y1,double x2,double y2)
{
    return (x0*y1+x2*y0+x1*y2-x2*y1-x0*y2-x1*y0)/2.0;
}
int main()
{
    for(int i=0;i<3;i++)
        scanf("%lf%lf",&p[i].x,&p[i].y);
    ans=circumcenter(p[0],p[1],p[2]);
    Line x[3];
    x[0].distance=dis(p[1],p[2]);
    x[1].distance=dis(p[0],p[2]);
    x[2].distance=dis(p[0],p[1]);
    x[0].a=p[1],x[0].b=p[2];
    x[1].a=p[0],x[1].b=p[2];
    x[2].a=p[0],x[2].b=p[1];
    for(int i=0;i<3;i++)
        x[i].jiao=cal(x[i]);
    sort(x,x+3,cmp);
    //printf("%lf....%lf\n",x[0].a.x,x[0].a.y);
    //printf("%lf....%lf\n",x[0].b.x,x[0].b.y);
    //printf("%lf\n",acos(x[0].jiao));
    double ccc=2*PI/acos(x[0].jiao);
    //printf("%lf\n",ccc);
    double mmmm=ccc*area(ans.x,ans.y,x[0].a.x,x[0].a.y,x[0].b.x,x[0].b.y);
    mmmm<0?(mmmm*=-1):1;
    printf("%.8lf\n",mmmm);
    return 0;
}

换方法之后,果然过了。

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
#define pi 3.1415926
#define eps 10e-3
typedef struct point
{
    double x,y;
};
double area(double x0,double y0,double x1,double y1,double x2,double y2)
{
    return 0.5*fabs(x0*y1+x2*y0+x1*y2-x2*y1-x0*y2-x1*y0);
}
double dis(point a,point b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
point p[3];
bool is_ok(int n,double jiao)
{
    double cnt=n*jiao/pi;
    double pnt=floor(cnt+eps);
    if(cnt-pnt<eps)
        return true;
    return false;
}
int main()
{
    for(int i=0;i<3;i++)
        scanf("%lf%lf",&p[i].x,&p[i].y);
    double a=dis(p[0],p[1]);
    double b=dis(p[0],p[2]);
    double c=dis(p[1],p[2]);
    double A=acos((b*b+c*c-a*a)/2/b/c);
    double B=acos((a*a+c*c-b*b)/2/a/c);
    double C=acos((b*b+a*a-c*c)/2/b/a);
    double r=a*b*c/area(p[0].x,p[0].y,p[1].x,p[1].y,p[2].x,p[2].y)/4;
    //double jiao=max(A,max(B,C)); 开始我觉得下面的is_ok函数只要判断jiao就可以了
	// 其实还是会WA 第五组数据。。。WA的时候答案是输出的两倍,Wa的厉害了
    int n;
    for(n=3;n<=100;n++)
        if(is_ok(n,A)&&is_ok(n,B)&&is_ok(n,C))
            break;
    double tag=2*pi/n;
    double Area=n*r*r*sin(tag)/2;
    printf("%.8lf\n",Area);
    return 0;
}


评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值