codeforces beta round 1

codeforces beta round 1

A

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 6 4

output

4

题意:n * m大的剧场,a*a大的砖块,允许超过覆盖面积,不允许打破砖块,输出所需的砖块数量

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ll n, m, x;
    cin >> n >> m >> x;
    ll ax = 0, ay = 0;
    ax = n/x + (n%x != 0);
    ay = m/x + (m%x != 0);
    cout << ax*ay << endl;
    return 0;
}

B

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

题意:在流行的电子表格系统中(例如,在Excel中),使用了以下的列数编号。第一列是数字A,第二列是数字B,等等,直到第26列被标记为Z,然后是两个字母的数字:第27列有数字AA,28-AB,第52列被标记为AZ。ZZ之后是三个字母的数字,等等。
单元格的名称是列号和行号的连接。例如,BC23是位于第55列、第23行的单元格的名称。
有时也会使用另一种数字系统。RXCY,其中X和Y是整数,分别表示列和行的数字。例如,R23C55是前面例子中的单元格。
你的任务是编写一个程序,读取给定的单元格坐标序列,并根据另一种计数系统的规则生成每个项目。

#include<bits/stdc++.h>
using namespace std;
//代码渣,体谅一下
void atb(string s)                        //BC23 => R23C55的过程
{
    int l = 0, h = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] >= '0' && s[i] <= '9')
        {
            h *= 10;
            h += s[i] - '0';
        }
        else
        {
            l *= 26;
            l += s[i] - 'A' + 1;
        }
    }
    cout << 'R' << h << 'C' << l << endl;
}

void bta(string s)                  //R23C55 => BC23的过程
{
    int l = 0, h = 0;
    int n = s.size();
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'R')
        {
            for(int j = i+1; j < n; j++)
            {
                if(s[j] == 'C')
                {
                    i = j;
                    break;
                }
                h *= 10;
                h += s[j] - '0';
            }
            for(int j = i+1; j < n; j++)
            {
                l *= 10;
                l += s[j] - '0';
            }
        }
    }
    int cnt = 0;
    char str[1000] = {0};
    while(l)
    {
        int k = l%26;
        if(k == 0)
        {
            str[cnt++] = 'Z';
            l -= 26;
        }
        else
        {
            str[cnt++] = 'A'-1+k;
        }
        l /= 26;
    }
    for(int i = cnt - 1; i >= 0; i--)
    {
        cout << str[i];
    }
    cout << h << endl;
}

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        string s;
        cin >> s;
        int b = 0;
        for(int i = 0; i < s.size() - 1; i++)
        {
            if(s[i] >= '0' && s[i] <= '9' && s[i+1] == 'C')
            {
                b = 1;
                break;
            }
        }
        if(b)
        {
            bta(s);
        } 
        else
        {
            atb(s);
        }
    }
}

C3

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

题意:现在,伯尔尼的所有马戏团都有一个直径为13米的圆形竞技场,但在过去情况有所不同。
在古代贝兰,马戏团的竞技场是一个规则的(等边)多边形,其大小和角度的数量可能因马戏团而异。竞技场的每个角落都有一个特殊的柱子,柱子之间的绳子标志着竞技场的边缘。
最近,来自Berland的科学家发现了古代马戏团竞技场的遗迹。他们只发现了三根柱子,其他的都被时间摧毁了。
你会得到这三根柱子的坐标。找出竞技场最小的面积是多少。

#include<bits/stdc++.h>
using namespace std;

//通过三点坐标求剧场面积
//已知所有的点都在正多边形的外接圆上
//找出圆心,求角度的最大公因数

const double emp = 1e-4;
const double pi = acos(-1);

double fgcd(double a, double b)
{
    return a <= emp ? b : fgcd(fmod(b, a), a);
}

int main()
{
    double x1, y1, x2, y2, x3, y3;//坐标
    double a, b, c, p, s, r, k;//边长,半径,面积,斜率等
    double da, db, dc;//角度
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    cin >> x3 >> y3;
    a = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
    b = sqrt((x1 - x3)*(x1 - x3) + (y1 - y3)*(y1 - y3));
    c = sqrt((x2 - x3)*(x2 - x3) + (y2 - y3)*(y2 - y3));
    p = (a + b + c)/2.0;
    s = sqrt(p*(p - a)*(p - b)*(p - c));
    r = a*b*c/(4*s);//三角形外接圆半径公式
    da = 2*acos((b*b+c*c-a*a)/(2*b*c));//余弦定理求角度,圆心角是圆周角的二倍
    db = 2*acos((a*a+c*c-b*b)/(2*a*c));
    dc = 2*pi - da - db;
    p = fgcd(da, db);
    p = fgcd(p, dc);
    printf("%.7lf\n", pi*r*r*sin(p)/p);
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值