https://nanti.jisuanke.com/t/43390

题意

  几何中心重合的 圆 和 正方形

  给定正四边形边长 a 和 圆的半径 r,求重合面积

  简单计算几何问题

思路

  分块计算

  注意精度和舍入问题

代码

  

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include <vector>
#include <iterator>
#include <utility>
#include <sstream>
#include <limits>
#include <numeric>
#include <functional>
using namespace std;
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
//#define sort(a,n,int) sort(a,a+n,less<int>()) #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef char ch;
typedef double db; const double PI=acos(-1.0);
const double eps=1e-6;
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10; bool compare(int a, int b)
{
return a < b;//升序
} double pi = 3.14159265358979;
int main(){
double s = 0;
double r = 0;
int t = 0;
cin >> t;
while(t--)
{
cin >> s >> r;
if(r > s*sqrt(2)/2)
{
//cout<<" !1 ";
cout <<s*s <<endl;
continue;
}
if(r < s/2)
{
//cout<<" !2 ";
cout <<pi*r*r <<endl;
continue;
}
double d = sqrt(r*r - s*s/4);
double s1 = d*s*2;
double a = acos(s/r/2);
//cout<<a<<endl;////
double s2 = pi*r*r * (1-a/(2*pi)*8);
cout <<fixed <<setprecision(2) <<s1 + s2 <<endl;
}
return 0;
}

  

E . Rain Gauge -UCF Local Programming Contest 2015的更多相关文章

  1. 04.06 UCF Local Programming Contest 2017

    A.Electric Bill 题意:简单计算题,超过1000部分额外算 1 #include<stdio.h> 2 int main(){ 3 int money1,money2; 4 ...

  2. UCF Local Programming Contest 2016 J题(二分+bfs)

    题目链接如下: https://nanti.jisuanke.com/t/43321 思路: 显然我们要采用二分的方法来寻找答案,给定一个高度如果能确定在这个高度时是否可以安全到达终点,那我们就可以很 ...

  3. 03.28,周六,12:00-17:00,ICPC训练联盟周赛,选用试题:UCF Local Programming Contest 2016正式赛。

    A. Majestic 10 题意:三个数均大于10则输出"triple-double",如果两个数大于10则输出"double-double",如果一个大于1 ...

  4. 03.21 ICPC训练联盟周赛:UCF Local Programming Contest 2018正式赛

    B Breaking Branches 题意:两个人比赛折枝,谁剩下最后1,无法折出整数即为输 思路:树枝长n,若是奇数,则Bob胜出,若是偶数,则Alice胜出,且需要输出1: 1 #include ...

  5. 2020.3.28-ICPC训练联盟周赛,选用试题:UCF Local Programming Contest 2016

    A.Majestic 10 签到题. #include<iostream> #include<cstdio> #include<cstring> #include& ...

  6. UCF Local Programming Contest 2018 C. First Last Sorting 思维、简单DP

    C. First Last Sorting链接:https://nanti.jisuanke.com/t/44141

  7. German Collegiate Programming Contest 2015 计蒜课

    // Change of Scenery 1 #include <iostream> #include <cstdio> #include <algorithm> ...

  8. Nordic Collegiate Programming Contest 2015​ B. Bell Ringing

    Method ringing is used to ring bells in churches, particularly in England. Suppose there are 6 bells ...

  9. Nordic Collegiate Programming Contest 2015​ G. Goblin Garden Guards

    In an unprecedented turn of events, goblins recently launched an invasion against the Nedewsian city ...

  10. Nordic Collegiate Programming Contest 2015​ E. Entertainment Box

    Ada, Bertrand and Charles often argue over which TV shows to watch, and to avoid some of their fight ...

随机推荐

  1. Target JRE version (1.8.0_201) does not match project JDK version (java version "1.7"), will use sources from JDK: 1.8

    问题描述:IntelliJ IDEA 启动项目时,常常提示Target JRE version (1.8.0_201) does not match project JDK version (java ...

  2. 前端WebSocket的方法封装

    一.封装方法 在项目根目录src下的utils中新增webSocketManager.js封装文件,代码内容如下: // webSocketManager.js /** WebSocketMessen ...

  3. 一个基于 .NET 8 开源免费、高性能、低占用的博客系统

    前言 今天大姚给大家分享一个基于 .NET 8 开源免费(MIT license).高性能.高安全性.低占用的博客系统:Masuit.MyBlogs. 项目介绍 Masuit.MyBlogs 是一个基 ...

  4. 《刚刚问世》系列初窥篇-Java+Playwright自动化测试-20- 操作鼠标拖拽 - 上篇(详细教程)

    1.简介 本文主要介绍两个在测试过程中可能会用到的功能:在selenium中宏哥介绍了Actions类中的拖拽操作和Actions类中的划取字段操作.例如:需要在一堆log字符中随机划取一段文字,然后 ...

  5. UFT Wscripts.Shell & Mercury.DeviceReplay

  6. 盘古信息PCB行业解决方案:以全域场景重构,激活智造新未来

    一.破局:PCB行业的时代之问 在数字经济蓬勃发展的浪潮中,PCB(印制电路板)作为 "电子产品之母",其重要性愈发凸显.随着 5G.人工智能等新兴技术的加速渗透,PCB行业面临着 ...

  7. HTML CSS 垂直居中布局

    display:flex;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-line ...

  8. vue中如何使用prismjs

    安装 yarn add prismjs 基本使用 <template> <code v-html="Prism.highlight(myJsonStr, Prism.lan ...

  9. 【8*】Slope Trick 学习笔记

    前言 从 一些快速笔记 中分离出来的,因为这一知识点写的内容太多了,可以拿出来专门开一篇学习笔记. Slope Trick 不是斜率优化!Slope Trick 不是斜率优化!Slope Trick ...

  10. FILE LINE 调试手段.

    __FILE__,__LINE__ 输出什么文件,输出在代码里面的多少行 首先在头部使用这个 #define __DEBUG__ #ifdef __DEBUG__ #define DEBUG(form ...