Codeforces Round#1
A. Theatre Square
题目大意:有一个长宽为m和n的广场,用边长为a的正方形去铺盖,问铺满最少需要多少正方形
题解:题目分解为用长度为a的线条分别去覆盖长度为m和n的线条,计算两者的乘积就是答案,在计算时注意整除的情况以及需要开long long防止相乘时范围越界。
#include <iostream>
using namespace std;
int main(){
long long n,a,m,p1,p2;
cin>>n>>m>>a;
if(n%a)p1=n/a+1; else p1=n/a;
if(m%a)p2=m/a+1; else p2=m/a;
cout<<p1*p2<<endl;
return 0;
}
B. Spreadsheet
题目大意:给出两种表达式,根据规则相互转化:一种是RXCY,一种是(字母)(数字),其中第一种变成第二种就是把X原封不动地拿回来,然后Y数字转化为数字,转化规则是,A-Z:1-26,AA-AZ:27-52,BA-BZ……依此类推,比如R23C55就可以转化成BC23。
题解:进制转化类的问题,注意转化方式特殊,在转化中刚好可以整除时需要特判,此外,首先对于原码格式的判断也要注意,我选择的标志是R和C还有数字的位置。
#include <cstdio>
#include <cstring>
using namespace std;
char s[1000005],l;
void change(){
int f=0,res=0,res1=0;
for(int i=0;i<l;i++){
if(s[i]>='A'&&s[i]<='Z'){res=res*26+s[i]-'A'+1;}
else{f=i;break;}
}for(int i=f;i<l;i++)res1=res1*10+s[i]-'0';
printf("R%dC%d\n",res1,res);
}
void change1(){
int res=0,res1=0,f=0,x[10005];x[0]=0;
for(int i=1;i<l;i++){
if(s[i]>='A'&&s[i]<='Z'){f=i;break;}
else{res=res*10+s[i]-'0';}
}for(int i=f+1;i<l;i++)res1=res1*10+s[i]-'0';
while(res1){
if(res1%26==0){x[++x[0]]=26;res1-=26;res1/=26;}
else{x[++x[0]]=res1%26;res1/=26;}
}for(int i=x[0];i;i--)printf("%c",'A'+x[i]-1);
printf("%d\n",res);
}
int main(int T){
scanf("%d",&T);
while(T--){
scanf(" %s",s);
int flag=1; l=strlen(s);
if(s[0]=='R'){
if(s[1]>='A'&&s[1]<='Z'){flag=1;}
else for(int i=2;i<l;i++)if(s[i]=='C'){flag=0;}
}if(flag){change();}else change1();
}return 0;
}
C. Ancient Berland Circus
题目大意:给出一个正多边形上的三个点,求这个正多边形的最小面积。
题解:由给出的三个点,可以得出这个三角形的外接圆,即这个多边形的外接圆。根据三边计算对应的圆心角,求出它们的最大公约数,就可以得到多边形的边数,有了半径和边数,就可以计算出相应的面积了,需要注意的是,在计算最长边的圆心角时,考虑钝角的问题,所以用剩余的两个小角去计算。
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
const double EPS=0.01;
const double PI=3.1415926535897932384626;
double gcd(double a,double b){return b<EPS?a:gcd(b,fmod(a,b));}
double dist(double x1,double y1,double x2,double y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
int main(){
double a[3],A[3],p,c,x1,x2,x3,y1,y2,y3,s,r,k;
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
a[0]=dist(x1,y1,x2,y2);a[1]=dist(x1,y1,x3,y3);a[2]=dist(x2,y2,x3,y3);
sort(a,a+3); p=(a[0]+a[1]+a[2])/2.0;
s=sqrt(p*(p-a[0])*(p-a[1])*(p-a[2]));
r=a[0]*a[1]*a[2]/(4*s);
A[0]=2*asin(a[0]/(2*r));
A[1]=2*asin(a[1]/(2*r));
A[2]=2*PI-A[1]-A[0];
p=gcd(A[2],gcd(A[1],A[0]));
printf("%.6lf\n",(PI*r*r*sin(p))/p);
return 0;
}
Codeforces Round#1的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #370 - #379 (Div. 2)
题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #284 (Div. 2)A B C 模拟 数学
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- Python进阶之面向对象编程(二)
Python面向对象编程(二) .note-content {font-family: "Helvetica Neue",Arial,"Hiragino Sans GB& ...
- 移动web开发
在现代网页开发中,新增了一个移动设备网页开发,在这样的需求下,你需要考虑如何将移动web和pc web同步处理 /* * 浏览器如何识别移动设备 * */ var ua = navigator.use ...
- Flink资料(7) -- 背压监控
背压(backpressure)监控 本文翻译自Back Pressure Monitoring --------------------------------------------------- ...
- codeforces 659D . Bicycle Race 几何
题目链接 对相邻的三个点叉积判断一下就好. #include <iostream> #include <vector> #include <cstdio> #inc ...
- C语言Printf格式
使用printf打印时发现,如果数据类型和打印使用的类型不一致,结果就是混乱的. 这是因为printf本身并不进行数据的类型转换,他只是把输入按照给定的数据格式输出,如果二者不匹配,那么由于不同数据类 ...
- Httpwatch 工具介绍
一 概述: HttpWatch强大的网页数据分析工具.集成在Internet Explorer工具栏.包括网页摘要.Cookies管理.缓存管理.消息头发送/接受.字符查询.POST 数据和目录管理功 ...
- SQL Server 一些重要视图2
1. sys.dm_tran_session_transactions 为每一个没有关闭的事务返回一行.session_id 可以与sys.dm_exec_connections.session_id ...
- SQL Server 行的删除与修改-------------(未完待续P222 deep SQL Server 222 )
删除: 1.堆表:当行被删除时,不会自动重新组织页面上的空间.删除行时不会从物理页面上删除, 而只是把行偏移设置为 0 .表示空间没有使用.除了页面上没有被回收空间之外,堆中的 空白页也常常不会被回收 ...
- js获取宽度设置thickbox百分比
thickbox的宽高不好设为百分比,这样遇到不同的尺寸的电脑就会出现问题. 怎么做呢? 通过js来处理. <script type="text/javascript"> ...
- DELL服务器安装Windows server 2003---解决找不到安装在计算机上的硬盘驱动器 安装无法
安装Windows server 2003系统,本以为改改BIOS配置“改为从光驱启动优先”很容易搞定的.没想到系统安装过程中碰到“找不到安装在计算机上的硬盘驱动器安装无法继续,要退出请按F3”问题, ...