Codeforces Beta Round #1 ABC

看到别人在写。。。于是也想写一下。。。

第一题纯水题,第二题字符串处理+进制转换水题,第三题计算几何水题。 话说这个是水题赛么

不过计算几何不会,于是看着别人的代码写的。寒假争取填坑

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

#include <iostream>
using namespace std;
int main()
{
	long long a,b,c,d,e;
	cin>>a>>b>>c;
	a=a%c?a/c+1:a/c;
	b=b%c?b/c+1:b/c;
	cout<<a*b<<endl;
	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

#include <iostream>
using namespace std;
string s;
int n,i,l,r,c,t;
void print(int);
int main()
{
	cin>>n;
	while (n--){
		cin>>s;
		l=s.size();
		r=c=0;
		if (s[0]=='R' && s[1]<='9' && (t=s.find('C'))>0){
			for (i=t+1;i<l;++i) 
				c=c*10+(s[i]-'0');
			print(c);
			cout<<s.substr(1,t-1)<<endl;
		}
		else{
			for (i=0;i<l;++i)
				if (s[i]<'A'){
					t=i; break;
				}
			for (i=0;i<t;++i)
				r=r*26+(s[i]-'A'+1);
				cout<<'R'<<s.substr(t)<<'C'<<r<<endl;
		}
	}
	return 0;
}

void print(int x){
	if (x>0){
		if (x%26){
			print(x/26);
			cout<<char(x%26+'A'-1);
		}
		else{
			print(x/26-1);
			cout<<'Z';
		}
	}
	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.

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

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

const double PI=acos(-1.0);
const double EPS=1e-4;

double x[3],y[3],d[3],ang[3];
int i;

bool feq(double x,double y){
	return fabs(x-y)<EPS;
}

double fgcd(double a,double b){
	if(feq(a,0)) return b;
	if(feq(b,0)) return a;
	return fgcd(b,fmod(a,b));
}

double dis(int a,int b){
	return sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
}

int main()
{
	for(i=0;i<3;++i)
		cin>>x[i]>>y[i];
	for(i=0;i<3;++i)
		d[i]=dis(i,(i+1)%3);
		
	double p=(d[0]+d[1]+d[2])/2;
	double s=sqrt(p*(p-d[0])*(p-d[1])*(p-d[2]));
	double r=d[0]*d[1]*d[2]/(s*4);
	for(i=0;i<2;i++)
		ang[i]=acos(1-d[i]*d[i]/(2*r*r));
	ang[2]=2*PI-ang[0]-ang[1];
	double angle=fgcd(ang[0],fgcd(ang[1],ang[2]));
	printf("%.6f\n",r*r*sin(angle)/2*(2*PI/angle));
	return 0;
}
copy:https://github.com/illuz/WayToACM/blob/master/CodeForces/1/1c.cpp


kdwycz的网站:  http://kdwycz.com/

kdwyz的刷题空间:http://blog.csdn.net/kdwycz



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值