Codeforces Beta Round #1 补题题解
A Theatre Square(数学)
算出每行能装多少乘以每列能装多少就行
公式
ans=ceil(n/a)+ceil(m/a)
代码
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n,m,a;
cin>>n>>m>>a;
cout<<(n/a+(n%a!=0))*(m/a+(m%a!=0));
}
B Spreadsheets(字符串模拟)
先得看出这是一个26进制的转换然后会发现一个问题,这个26进制从1开始到26跟一般的从0-25是有区别的
解决的办法是转换的时候统一用m-1替换m但是条件还是判断m是不是等于0
sscanf真心好用啊
代码
#include <bits/stdc++.h>
char s[666666],ss[666666];
void print(int x)
{
if(!x)
return;
print((x-1)/26);
putchar('A'+(x-1)%26);
}
int main()
{
int t,n,m;
scanf("%d",&t);
while(t--)
{
double sum=0;
scanf("%s",s);
if(sscanf(s,"R%dC%d",&n,&m)==2)
print(m),printf("%d\n",n);
else
{
sscanf(s,"%[A-Z]%d",ss,&n);
int len=strlen(ss);
for(int i=0;i<len;i++)
sum+=(ss[i]-'A'+1)*pow(26,len-i-1);
printf("R%dC%.0f\n",n,sum);
}
}
}
C Ancient Berland Circus(数学)
完全的高考题,可以出在高考第一个数学大题,三角函数上
给定平面内的三个点,计算由这三个点构成的正多边形的面积
首先计算出外接圆
外接圆的公式是abc/4s
abc是三个点组成的三条线段的长度
s是三角形的面积
s可以用海伦公式求
s=sqrt(p(p-a)(p-b)(p-c))
其中p=(a+b+c)/2
然后计算多边形的边数
先求出三角形的三个内角用余弦定理
例如角A=acos((bb+cc-aa)/(2b*c))
其他的一样
然后找出三个角的最大公因数ang=gcd(A,B,C)=gcd(gcd(A,B),C)
边数n=pi/ang
这里因为圆周角是圆心角的一半所以原本的公式是2pi/2ang化简得到n=pi/ang
然后正多边形的面积就是n个等腰三角形的面积也就是
S=n1/2rrsin(2*pi/n)
代码
#include <bits/stdc++.h>
using namespace std;
double gcd(double a,double b)
{
return a<0.01?b:gcd(fmod(b,a),a);
}
double pi=acos(-1);
int main()
{
/*ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);*/
double x1,y1,x2,y2,x3,y3;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
double a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
double b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
double c=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
double p=(a+b+c)/2;
double s=sqrt(p*(p-a)*(p-b)*(p-c));
double r=(a*b*c)/(4*s);
double A=acos((b*b+c*c-a*a)/(2*b*c));
double B=acos((a*a+c*c-b*b)/(2*a*c));
double C=acos((a*a+b*b-c*c)/(2*b*a));
double ang=gcd(gcd(A,B),C);
double n=pi/ang;
printf("%.6f",n/2.0*r*r*sin(2*pi/n));
}
Codeforces Beta Round #1 补题题解的更多相关文章
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- 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 #62 题解【ABCD】
Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...
- 水题 Codeforces Beta Round #70 (Div. 2) A. Haiku
题目传送门 /* 水题:三个字符串判断每个是否有相应的元音字母,YES/NO 下午网速巨慢:( */ #include <cstdio> #include <cstring> ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #17 D. Notepad (数论 + 广义欧拉定理降幂)
Codeforces Beta Round #17 题目链接:点击我打开题目链接 大概题意: 给你 \(b\),\(n\),\(c\). 让你求:\((b)^{n-1}*(b-1)\%c\). \(2 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- Codeforces Beta Round #70 (Div. 2)
Codeforces Beta Round #70 (Div. 2) http://codeforces.com/contest/78 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #63 (Div. 2)
Codeforces Beta Round #63 (Div. 2) http://codeforces.com/contest/69 A #include<bits/stdc++.h> ...
随机推荐
- Pow(x, n) 位运算总结 典型
https://leetcode.com/problems/powx-n/ Implement pow(x, n), which calculates x raised to the power n ...
- javascript复制内容到剪切板/网页上的复制按钮的实现
javascript复制内容到剪切板/网页上的复制按钮的实现:DEMO如下 <!doctype html> <html> <head> <meta chars ...
- Ubuntu 安装MTP驱动访问安卓设备(转载)
转自:http://www.ipython.me/ubuntu/how-to-connect-kindle-with-ubuntu.html 1.安装MTP工具集: mr_liu@i-it:~$ su ...
- vultr 购买vps
基本安装转自:https://github.com/uxh/shadowsocks_bash/wiki/Vultr%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B 连接 Vul ...
- python之定时器Timer
timer类 Timer(定时器)是Thread的派生类,用于在指定时间后调用一个方法. 构造方法: Timer(interval, function, args=[], kwargs={}) in ...
- mybatis-plus 获取新增id
<insert id="insert" parameterType="com.xxx.xxxx.pojo.User"> insert into t_ ...
- 数学/找规律/暴力 Codeforces Round #306 (Div. 2) C. Divisibility by Eight
题目传送门 /* 数学/暴力:只要一个数的最后三位能被8整除,那么它就是答案:用到sprintf把数字转移成字符读入 */ #include <cstdio> #include <a ...
- 等待进程结束函数中的BUG
偶然发现一个BUG,有一个函数是这样写的: void WaitProcExit(DWORD dwPid) { HANDLE hProcess = OpenProcess(PROCESS_ALL_ACC ...
- Sql Server把本地数据库传到服务器数据库
上一篇文章我们已经把网站布署到服务器中了,如果是动态网站肯定是有数据库的,接下来通过Sql Server把本地数据库上传到服务器数据库中. 打开Sql Server连接本地数据库,选中要导出的数据库, ...
- ajax通过新闻id获取列表
<div class="index_main"> <div class="page_l"> <i ...