zoukankan      html  css  js  c++  java
  • CodeForces 1

     A- Theatre Square
    Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    Description

    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 Input

    Input
    6 6 4
    Output
    4
    题意:给出n*m的广场,用a*a的花岗石铺,求最少的花岗石个数。要求花岗石不能切割,铺的时候边界必须和广场边界平行。
    #include <iostream>
    #include <cstdio>
    #include <queue>
    #include <cstring>
    using namespace std;
    #define ll long long
    
    int main()
    {
        ll n,m,a;
        while(scanf("%lld%lld%lld",&n,&m,&a)!=EOF)
        {
            ll k1=n/a;
            if(n%a) k1++;
            ll k2=m/a;
            if(m%a) k2++;
            printf("%lld
    ",k1*k2);
        }
        return 0;
    }
    B - Spreadsheets
    Time Limit:10000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    Description

    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 than106 .

    Output

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

    Sample Input

    Input
    2 R23C55 BC23
    Output
    BC23 R23C55
    题意:EXCEL中字母序号与数字的转换。
    #include <iostream>
    #include <cstdio>
    #include <queue>
    #include <cstring>
    using namespace std;
    #define ll long long
    
    int bit[1010];
    char s[1010];
    
    void print(int n)
    {
        int len=0;
        while(n)
        {
            bit[len++]=n%26;
            if(bit[len-1]==0) bit[len-1]=26;
            n--;
            n/=26;
        }
        for(int i=len-1;i>=0;i--) printf("%c",bit[i]+'A'-1);
    }
    int main()
    {
        int T;
        scanf("%d",&T);
        while(T--)
        {
            scanf("%s",s);
            int op=2,kk=0;
            int len=strlen(s);
            for(int i=0;i<len;i++)
            {
                if(s[i]=='R' && s[i+1]>='0' && s[i+1]<='9')
                {
                    kk++;
                }
                if(s[i]=='C' && s[i+1]>='0' && s[i+1]<='9')
                {
                    kk++;
                }
            }
            if(kk==2) op=1;
            if(op==1)
            {
                int r=0,c=0,flag=0;
                for(int i=1;i<len;i++)
                {
                    if(s[i]=='C') flag=1;
                    else
                    {
                        if(!flag) r=r*10+s[i]-'0';
                        else c=c*10+s[i]-'0';
                    }
                }
                print(c);
                printf("%d
    ",r);
            }
            else
            {
                int c=0,r=0,flag=0;
                for(int i=0;i<len;i++)
                {
                    if(s[i]>='0'&& s[i]<='9') flag=1;
                    if(!flag) c=c*26+s[i]-'A'+1;
                    else r=r*10+s[i]-'0';
                }
                printf("R%dC%d
    ",r,c);
            }
        }
        return 0;
    }
    C - Ancient Berland Circus
    Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    Description

    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 Input

    Input
    0.000000 0.000000 1.000000 1.000000 0.000000 1.000000
    Output
    1.00000000
    题意:有一个圆形的斗兽场,圆上有多个树桩,刚好能组成一个正多边形的舞台,但是目前只知道3个树桩的坐标,求最小的舞台面积。
    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <cmath>
    #include <algorithm>
    using namespace std;
    #define PI acos(-1.0)
    #define EPS 0.01
    
    struct Point
    {
        double x,y;
        Point(){}
        Point(double x,double y):x(x),y(y){}
        Point operator - (Point p)
        {
            return Point(x-p.x,y-p.y);
        }
        double operator * (Point p)
        {
            return x*p.x+y*p.y;
        }
        double getlen()
        {
            return sqrt(x*x+y*y);
        }
    }p[3];
    Point waixin(Point a,Point b,Point c)
    {
        double a1=b.x-a.x,b1=b.y-a.y,c1=(a1*a1+b1*b1)/2;
        double a2=c.x-a.x,b2=c.y-a.y,c2=(a2*a2+b2*b2)/2;
        double d=a1*b2-a2*b1;
        return Point(a.x+(c1*b2-c2*b1)/d,a.y+(a1*c2-a2*c1)/d);
    }
    double PointToPoint(Point a,Point b)
    {
        return sqrt((a-b)*(a-b));
    }
    double gcd(double a,double b)
    {
        return a<EPS?b:gcd(fmod(b,a),a);
    }
    int main()
    {
        double l[3];
        while(scanf("%lf%lf%lf%lf%lf%lf",&p[0].x,&p[0].y,&p[1].x,&p[1].y,&p[2].x,&p[2].y)!=EOF)
        {
            Point w=waixin(p[0],p[1],p[2]);
            double r=PointToPoint(w,p[0]);
            l[0]=(p[0]-p[1]).getlen();
            l[1]=(p[1]-p[2]).getlen();
            l[2]=(p[2]-p[0]).getlen();
    
            sort(l,l+3);
    
            double angel1=2*asin(l[0]/2/r);
            double angel2=2*asin(l[1]/2/r);
    
            double angel3=2*PI-angel1-angel2;
    
            double angel=gcd(gcd(angel1,angel2),angel3);
            double n=2*PI/angel;
    
            double s=0.5*n*r*r*sin(angel);
    
            printf("%.6f
    ",s);
        }
        return 0;
    }
    趁着还有梦想、将AC进行到底~~~by 452181625
  • 相关阅读:
    出现org.apache.ibatis.binding.BindingException异常
    EasyExcel读写操作
    window下运行nginx出现nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
    vue Module build failed: Error: Missing binding E:vuevue-demo ode_modules ode-sa ssvendorwin64
    Axios谷粒学院学习
    springboot中数据库的连接
    多表删除,删除一个表的同时删除中间表
    今天写了一个SSM小项目,运行之后,前端页面的CSS、js样式显示不出来,具体操作如下:
    Java中Iterator(迭代器)实现原理
    写一些东西,记录一下成长的过程
  • 原文地址:https://www.cnblogs.com/hate13/p/4344279.html
Copyright © 2011-2022 走看看