CodeForces 1
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
6 6 4
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\n",k1*k2);
}
return ;
}
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
2 R23C55 BC23
BC23 R23C55
题意:EXCEL中字母序号与数字的转换。
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;
#define ll long long int bit[];
char s[]; void print(int n)
{
int len=;
while(n)
{
bit[len++]=n%;
if(bit[len-]==) bit[len-]=;
n--;
n/=;
}
for(int i=len-;i>=;i--) printf("%c",bit[i]+'A'-);
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%s",s);
int op=,kk=;
int len=strlen(s);
for(int i=;i<len;i++)
{
if(s[i]=='R' && s[i+]>='' && s[i+]<='')
{
kk++;
}
if(s[i]=='C' && s[i+]>='' && s[i+]<='')
{
kk++;
}
}
if(kk==) op=;
if(op==)
{
int r=,c=,flag=;
for(int i=;i<len;i++)
{
if(s[i]=='C') flag=;
else
{
if(!flag) r=r*+s[i]-'';
else c=c*+s[i]-'';
}
}
print(c);
printf("%d\n",r);
}
else
{
int c=,r=,flag=;
for(int i=;i<len;i++)
{
if(s[i]>=''&& s[i]<='') flag=;
if(!flag) c=c*+s[i]-'A'+;
else r=r*+s[i]-'';
}
printf("R%dC%d\n",r,c);
}
}
return ;
}
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
0.000000 0.000000 1.000000 1.000000 0.000000 1.000000
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[];
Point waixin(Point a,Point b,Point c)
{
double a1=b.x-a.x,b1=b.y-a.y,c1=(a1*a1+b1*b1)/;
double a2=c.x-a.x,b2=c.y-a.y,c2=(a2*a2+b2*b2)/;
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[];
while(scanf("%lf%lf%lf%lf%lf%lf",&p[].x,&p[].y,&p[].x,&p[].y,&p[].x,&p[].y)!=EOF)
{
Point w=waixin(p[],p[],p[]);
double r=PointToPoint(w,p[]);
l[]=(p[]-p[]).getlen();
l[]=(p[]-p[]).getlen();
l[]=(p[]-p[]).getlen(); sort(l,l+); double angel1=*asin(l[]//r);
double angel2=*asin(l[]//r); double angel3=*PI-angel1-angel2; double angel=gcd(gcd(angel1,angel2),angel3);
double n=*PI/angel; double s=0.5*n*r*r*sin(angel); printf("%.6f\n",s);
}
return ;
}
CodeForces 1的更多相关文章
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
- CodeForces - 148D Bag of mice
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
- CodeForces - 453A Little Pony and Expected Maximum
http://codeforces.com/problemset/problem/453/A 题目大意: 给定一个m面的筛子,求掷n次后,得到的最大的点数的期望 题解 设f[i]表示掷出 <= ...
随机推荐
- 11_Servlet基础知识
[概念] Servlet通常被称为服务端小程序,是运行在服务端的程序,用于处理及相应客户端的请求. Servlet是用java语言开发网页动态资源的技术. [特点] 1.Servlet是个特殊的Jav ...
- 初学dorado
初学dorado 1.dorado使用视图来写界面代码,超级轻松:还需要画流程,页面间的跳转应该很轻松了. 2.先新建dorado项目,再创建dorado视图 3.在Servers里双击tomacat ...
- What are the differences between small, minor, and major updates?
Following contents are excerpted from the this website and only used for knowledge sharing: Install ...
- Ajax请求过程中显示“进度”的简单实现
Ajax在Web应用中使用得越来越频繁.在进行Ajax调用过程中一般都具有这样的做法:显示一个GIF图片动画表明后台正在工作,同时阻止用户操作本页面(比如Ajax请求通过某个按钮触发,用户不能频繁点击 ...
- AVPlayer 视频播放
1. AVPlayer AVPlayer 是一个用来播放基于时间的视听媒体的控制器对象(一个队播放和资源时间相隔信息进行管理的对象,而非一个视图或窗口控制器). AVPlayer支持播放从本地, 分步 ...
- js设置cookie过期及清除浏览器对应名称的cookie
js设置cookie过期也就相当于清除浏览器对应名称的cookie的例子. 代码: function ClearCookie() { var expires = new Date(); expir ...
- grep线上环境精典案例后续
请执行命令取出 linux 中 eth0 的 IP 地址(请用 cut,有能力者也可分别用 awk,sed 命令答). 自己的方法: [root@nginx_back ~]# ifconfig eth ...
- 聊聊iOS开发中耳机的那点事(监听耳机拔插、耳机线控)-b
如果说一个项目出现的最重大的事故,那无疑就是开发人员使用了不可控的元素. 前言 iOS开发当中有关于视音频播放的开发不在少数,用户时常会使用到一种输出设备,那就是"耳机",这一篇博 ...
- sizeof()和strlen()在求字符串长度时的差别
sizeof()函数输出字符串长度时会把结束符计算在内: strlen()函数输出字符串长度时不会把结束符计算在内. 如图:
- C#导入导出数据到Excel的通用类代码
Excel文件导入导出,需引用Microsoft Excel 11.0 Object Library ///////////////////////////////////////////////// ...