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

题目链接:http://codeforces.com/problemset/problem/1/A

分析:
题意:给你一个矩形的常和宽,以及边长为a的正方形砖块,用砖块去铺这个矩形,允许重叠,不难,记住开__int64,否则会WA!
下面给出AC代码:
 #include <bits/stdc++.h>
using namespace std;
int main()
{
__int64 n,m,a;
while(scanf("%I64d%I64d%I64d",&n,&m,&a)!=EOF)
{
__int64 t=n/a;
__int64 s=m/a;
if(n%a!=)
t+=;
if(m%a!=)
s+=;
__int64 k=t*s;
printf("%I64d\n",k);
}
return ;
}
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

题目链接:http://codeforces.com/problemset/problem/1/B

分析:          
题意:在Excel中,一个格子的位置有2种表示:

例如第23行第55列

①R23C55

②BC23

第一种表示方法很直观。

第二种表示方法中BC表示列。23表示行。

1-26列:A, B, C...Z

27-?列:AA, AB, AC...AZ, BA, BB, BC...ZZ

?-?:AAA...ZZZ...

跟进制的转换很类似!

输入任意一种表示,你的任务是输出另一种表示,模拟即可!
下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
const int maxn=;
typedef long long ll;
char str[maxn];
int flag;
void change(int n)//26进制转换
{
if(n>)
change((n-)/);
printf("%c",(n-)%+'A');
}
void solve1()
{
int row=;
int col=;
for(int i=;i<flag;i++)
if(isdigit(str[i]))
row=row*+str[i]-'';//计算行
for(int i=flag+;str[i];i++)
col=col*+str[i]-'';//计算列
change(col);
printf("%d\n",row);
}
void solve2()
{
int row=;
int col=;
for(int i=;str[i];i++)
{
if(isupper(str[i]))
col=col*+str[i]-'A'+;//计算列
else row=row*+str[i]-'';//计算行
}
printf("R%dC%d\n",row,col);
}
int main()
{
int T;
while(scanf("%d",&T)!=EOF)
{
while(T--)
{
scanf("%s",str);
flag=;
if(str[]=='R'&&isdigit(str[]))
{
for(int i=;str[i];i++)
{
if(str[i]=='C')
{
flag=i;
break;
}
}
}
if(flag)
solve1();//判断‘R23C55’这一种情况
else
solve2();//判断‘BC23’这一种情况
}
}
return ;
}
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

题目链接:http://codeforces.com/problemset/problem/1/C

分析:
题意:有一个正n边形

输入正n边形的其中3个点

问正n边形可能存在的最小面积,已知n<=100

该题关键技巧就是要画外接圆,然后玩玩圆周角,圆心角这些概念,当个平面几何问题,先尽量多推出一些结论。

具体解法如下:

首先,随便画个正多少边形,画个外接圆。根据正弦定理,可以直接知道外接圆半径。把这三个点连成一个三角形,三个角都会是正x边形的一个边对应这个外接圆的圆周角的整数倍。由于x很小,枚举+判断就可以了。

三角形外接圆半径公式:

每条边所对应的圆心角 = 2*PI/n

所以圆周角 = 圆心角/2 = PI/n

正n边形面积:

             

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
const double PI=3.1415926535;
const double ERR=0.01;
bool feq(double a,double b)
{
return fabs(a-b)<ERR;
}
double fgcd(double a,double b)
{
if (feq(a,))
return b;
if (feq(b,))
return a;
return fgcd(b,fmod(a,b));
}
double dist(double x0,double x1,double y0,double y1)
{
return sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
}
int main()
{
double x[];
double y[];
for (int i=;i<;i++)
scanf("%lf%lf",&x[i],&y[i]);
double l[];
for (int i=;i<;i++) l[i]=dist(x[i],x[(i+)%],y[i],y[(i+)%]);
double p=(l[]+l[]+l[])/;
double s=sqrt(p*(p-l[])*(p-l[])*(p-l[]));
double r=l[]*l[]*l[]/(s*);
double ang[];
for (int i=;i<;i++) ang[i] = acos(-l[i]*l[i]/(*r*r));
ang[] =*PI-ang[]-ang[];
double unita =;
for (int i=;i<;i++)
unita=fgcd(unita,ang[i]);
printf("%.6lf\n",r*r*sin(unita)*PI/unita);
return ;
}

Codeforces Beta Round #1 A,B,C的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  3. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  4. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  5. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  6. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  7. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  9. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  10. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

随机推荐

  1. JavaScript基础4——关于语句流程控制(分支语句、循环语句等)

    分支语句 (1)if...else...语句,基本格式分三种,如下 <script type="text/javascript"> var i=50; //if语句 i ...

  2. Visual Studio Code 快捷键大全(Windows)

    Visual Studio Code 是一款优秀的编辑器,非常适合编写 TS 以及 React .最近在学习 AngularJs 2,开始使用 VSCode,特意整理翻译了一下官网的快捷键.因为已经习 ...

  3. nodejs+mongodb+vue前后台配置ueditor

    笔者在做一个个人博客项目的时候需要一个富文本框输入组件与后台进行交互,但是官方配置里面没有关于nodejs的,于是自己查阅资料研究了一下,最后终于应用到了系统中. 一.后台配置 首先是找到了这个项目: ...

  4. n年前,我没钱但年轻,我怕n年后我老时,还是一无所成——2017我的收获和反思

    记得当年我刚从学校里出来时,应该和现在的95后差不多,当时还是很惶恐的,怕找不到工作,怕无法挣到足够的钱买房子支撑家庭,(当然还有其它的担心点),却唯独没意识到自己拥有着最宝贵的财富:年轻. 年轻意味 ...

  5. openstack操作之二 restful api

    Restful api 是openstack各服务调用的接口,简单理解为可以通过网络去调用的函数.postman是一款前端调用工具,测试后端接口的时候往往是使用该工具去验证.在openstack的使用 ...

  6. nginx搭建rtmp协议流媒体服务器总结

    最近在 ubuntu12.04+wdlinux(centos)上搭建了一个rtmp服务器,感觉还挺麻烦的,所以记录下. 大部分都是参考网络上的资料. 前提: 在linux下某个目录中新建一个nginx ...

  7. Linux(CentOS6.5)下Nginx注册系统服务(启动、停止、重启、重载等)&设置开机自启

    本文地址http://comexchan.cnblogs.com/ ,作者Comex Chan,尊重知识产权,转载请注明出处,谢谢! 完成了Nginx的编译安装后,仅仅是能支持Nginx最基本的功能, ...

  8. Spark 核心概念 RDD 详解

    RDD全称叫做弹性分布式数据集(Resilient Distributed Datasets),它是一种分布式的内存抽象,表示一个只读的记录分区的集合,它只能通过其他RDD转换而创建,为此,RDD支持 ...

  9. 封装简单的equery

    /** * Created by wang on 2016/3/23. */ //绑定操作 function bindEvent(obj,events,fn){ if (obj.addEventLis ...

  10. 队列详解及java实现

    导读 栈和队列是有操作限制的线性表. 目录 1.队列的概念.特点.存储结构. 2.栈队列的java实现. 概念 队列是一种在一端进行插入,而在另一端进行删除的线性表.1.队列的插入端称为队尾:队列的删 ...