Codeforces Beta Round #1 A,B,C
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.
The input contains three positive integer numbers in the first line: n, m and a (1 ≤ n, m, a ≤ 109).
Write the needed number of flagstones.
6 6 4
4
题目链接:http://codeforces.com/problemset/problem/1/A
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 __int64 n,m,a; 6 while(scanf("%I64d%I64d%I64d",&n,&m,&a)!=EOF) 7 { 8 __int64 t=n/a; 9 __int64 s=m/a; 10 if(n%a!=0) 11 t+=1; 12 if(m%a!=0) 13 s+=1; 14 __int64 k=t*s; 15 printf("%I64d\n",k); 16 } 17 return 0; 18 }
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.
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 .
Write n lines, each line should contain a cell coordinates in the other numeration system.
2 R23C55 BC23
BC23R23C55
题目链接:http://codeforces.com/problemset/problem/1/B
例如第23行第55列
①R23C55
②BC23
第一种表示方法很直观。
第二种表示方法中BC表示列。23表示行。
1-26列:A, B, C...Z
27-?列:AA, AB, AC...AZ, BA, BB, BC...ZZ
?-?:AAA...ZZZ...
跟进制的转换很类似!
输入任意一种表示,你的任务是输出另一种表示,模拟即可!
下面给出AC代码:
1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn=1000005; 4 typedef long long ll; 5 char str[maxn]; 6 int flag; 7 void change(int n)//26进制转换 8 { 9 if(n>26) 10 change((n-1)/26); 11 printf("%c",(n-1)%26+'A'); 12 } 13 void solve1() 14 { 15 int row=0; 16 int col=0; 17 for(int i=1;i<flag;i++) 18 if(isdigit(str[i])) 19 row=row*10+str[i]-'0';//计算行 20 for(int i=flag+1;str[i];i++) 21 col=col*10+str[i]-'0';//计算列 22 change(col); 23 printf("%d\n",row); 24 } 25 void solve2() 26 { 27 int row=0; 28 int col=0; 29 for(int i=0;str[i];i++) 30 { 31 if(isupper(str[i])) 32 col=col*26+str[i]-'A'+1;//计算列 33 else row=row*10+str[i]-'0';//计算行 34 } 35 printf("R%dC%d\n",row,col); 36 } 37 int main() 38 { 39 int T; 40 while(scanf("%d",&T)!=EOF) 41 { 42 while(T--) 43 { 44 scanf("%s",str); 45 flag=0; 46 if(str[0]=='R'&&isdigit(str[1])) 47 { 48 for(int i=2;str[i];i++) 49 { 50 if(str[i]=='C') 51 { 52 flag=i; 53 break; 54 } 55 } 56 } 57 if(flag) 58 solve1();//判断‘R23C55’这一种情况 59 else 60 solve2();//判断‘BC23’这一种情况 61 } 62 } 63 return 0; 64 }
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.
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 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.
0.000000 0.000000 1.000000 1.000000 0.000000 1.000000
1.00000000
题目链接:http://codeforces.com/problemset/problem/1/C
输入正n边形的其中3个点
问正n边形可能存在的最小面积,已知n<=100
该题关键技巧就是要画外接圆,然后玩玩圆周角,圆心角这些概念,当个平面几何问题,先尽量多推出一些结论。
具体解法如下:
首先,随便画个正多少边形,画个外接圆。根据正弦定理,可以直接知道外接圆半径。把这三个点连成一个三角形,三个角都会是正x边形的一个边对应这个外接圆的圆周角的整数倍。由于x很小,枚举+判断就可以了。
三角形外接圆半径公式:
每条边所对应的圆心角 = 2*PI/n
所以圆周角 = 圆心角/2 = PI/n
正n边形面积:
下面给出AC代码:
1 #include <bits/stdc++.h> 2 using namespace std; 3 const double PI=3.1415926535; 4 const double ERR=0.01; 5 bool feq(double a,double b) 6 { 7 return fabs(a-b)<ERR; 8 } 9 double fgcd(double a,double b) 10 { 11 if (feq(a,0)) 12 return b; 13 if (feq(b,0)) 14 return a; 15 return fgcd(b,fmod(a,b)); 16 } 17 double dist(double x0,double x1,double y0,double y1) 18 { 19 return sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)); 20 } 21 int main() 22 { 23 double x[3]; 24 double y[3]; 25 for (int i=0;i<3;i++) 26 scanf("%lf%lf",&x[i],&y[i]); 27 double l[3]; 28 for (int i=0;i<3;i++) l[i]=dist(x[i],x[(i+1)%3],y[i],y[(i+1)%3]); 29 double p=(l[0]+l[1]+l[2])/2; 30 double s=sqrt(p*(p-l[0])*(p-l[1])*(p-l[2])); 31 double r=l[0]*l[1]*l[2]/(s*4); 32 double ang[3]; 33 for (int i=0;i<3;i++) ang[i] = acos(1-l[i]*l[i]/(2*r*r)); 34 ang[2] =2*PI-ang[0]-ang[1]; 35 double unita =0; 36 for (int i=0;i<3;i++) 37 unita=fgcd(unita,ang[i]); 38 printf("%.6lf\n",r*r*sin(unita)*PI/unita); 39 return 0; 40 }
转载于:https://www.cnblogs.com/ECJTUACM-873284962/p/6533637.html
Codeforces Beta Round #1 A,B,C相关推荐
- Codeforces Beta Round #17 D. Notepad (数论 + 广义欧拉定理降幂)
Codeforces Beta Round #17 题目链接:点击我打开题目链接 大概题意: 给你 \(b\),\(n\),\(c\). 让你求:\((b)^{n-1}*(b-1)\%c\). \(2 ...
- Codeforces Beta Round #5 B. Center Alignment 模拟题
B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...
- Codeforces Beta Round #75 (Div. 1 Only) B. Queue 线段树。单点更新
http://codeforces.com/problemset/problem/91/B 题意: 给你n个数,求得i 到n中小于a[i]的最右边的a[j],然后求a[i]到a[j]之间包含了多少个数 ...
- Codeforces Beta Round #51 D. Beautiful numbers 数位dp + 状态优化
传送门 文章目录 题意: 思路: 题意: 思路: 数位dpdpdp挺经典的一个题辣,有一个很明显的状态就是f[pos][num][lcm]f[pos][num][lcm]f[pos][num][lcm ...
- Codeforces Beta Round #22 (Div. 2 Only) E. Scheme(DFS+强连通)
题目大意 给了 n(2<=n<=105) 个点,从每个点 u 出发连向了一个点 v(共 n 条边) 现在要求添加最少的边使得整个图是一个强连通图 做法分析 这道题千万不要一般化:先求强连通 ...
- codeforces beta round 1
codeforces beta round 1 A Theatre Square in the capital city of Berland has a rectangular shape with ...
- Codeforces Beta Round #4 (Div. 2 Only)
Codeforces Beta Round #4 (Div. 2 Only) A 水题 1 #include<bits/stdc++.h> 2 using namespace std; 3 ...
- Codeforces Beta Round #7
Codeforces Beta Round #7 http://codeforces.com/contest/7 A 水题 1 #include<bits/stdc++.h> 2 usin ...
- Codeforces Beta Round #2-A. Winner——算法笔记
题目链接:http://codeforces.com/problemset/problem/2/A 题目描述: The winner of the card game popular in Berla ...
最新文章
- vim的文件中字符串的查找与替换
- hypermesh 连接单元_西门子五件套L9型2M插头2兆线接头射频同轴电缆连接器三通双通头_...
- 16位模式/32位模式下PUSH指令探究——《x86汇编语言:从实模式到保护模式》读书笔记16
- 计算机基础- -应用和硬件的关系
- 挑战性题目DSCT101:硬币找换问题
- (转)关于最近疯狂流行的文件夹变成exe文件的病毒查杀办法
- VC2010升级到VC2015遇到问题及解决办法
- fedora14 安装
- 怎么将多个Excel工作簿合并成一个新的工作簿
- 谷歌邮箱lmap服务器填什么_Gmail IMAP的应用技巧
- CRMEB商城的新零售模式
- 《裸辞后,降薪找工作》
- 转载:CVPR 2019 论文汇总(按方向划分,0611 更新中)
- Anyka云平台调用api
- Python爬虫入门教程 40-100 博客园Python相关40W博客抓取 scrapy
- android上拉菜单和下拉菜单的实现
- c语言菜单即功能,C语言 菜单专题
- perforce p4v linux,Perforce p4v下载
- Opencv4.0学习记录(Day21 视频文件摄像头使用)
- 3.7V升压12V电路
热门文章
- 递归_三要素_基础算法必备
- Java工程师学习步骤
- sys.dbms_transaction.local_transaction_id出现的问题
- orakill和alter system kill session的区别
- 用户 NT AUTHORITY\NETWORK SERVICE 登录失败解决方法
- STM32使用FatFs
- 我的第一个python web开发框架(2)——一个简单的小外包
- [MSDN]每个开发人员现在应该下载的十种必备工具
- Wintellect Collection Classes for .NET now on CodePlex
- 如何计算和控制好项目开发成本?