lightoj1022Circle in Square

题意:求一个正方形中不被其内接圆覆盖的面积。已知其内接圆半径。

 1 //Accepted    1088 KB    0 ms
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 const double Pi=2*acos(0.0);
6 double ans,r;
7 double slove()
8 {
9 return 4*r*r-Pi*r*r;
10 }
11 int main()
12 {
13 int T;
14 scanf("%d",&T);
15 for (int t=1;t<=T;t++)
16 {
17 scanf("%lf",&r);
18 printf("Case %d: %.2f\n",t,slove()+1e-9);
19 }
20 return 0;
21 }

lightoj1022Circle in Square,布布扣,bubuko.com

时间: 2024-10-22 17:47:46

lightoj1022Circle in Square的相关文章

[leetcode] 367. Valid Perfect Square

Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function such as sqrt. Example 1: Input: 16 Returns: True Example 2: Input: 14 Returns: False 使用二分查找寻找input

Project Euler 92:Square digit chains C++

A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example, 44 → 32 → 13 → 10 → 1 → 1 85 → 89 → 145 → 42 → 20 → 4 → 16 → 37 → 58 → 89 Therefore any chain that

LeetCode Maximal Square

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Return 4. 思路分析:这题考察DP.缓存中间结果降低反复计算.DP方程为 if(matrix[i][j

Theatre Square 题解代码

Theatre Square CodeForces - 1A 水题水题... 最开始的程序是这个,可是AC不了我也不知道为什么......QAQ... #include <stdio.h>#include<stdlib.h>int main(){    int m,n,a,ans,tmp,k,h,tep,i,j;    scanf("%d %d %d",&m,&n,&a);    if(m%a==0)    {        if(n%a

[LeetCode] Matchsticks to Square 火柴棍组成正方形

Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, please find out a way you can make one square by using up all those matchsticks. You should not break any stick, but you can link them up, a

codeforces 710C C. Magic Odd Square(构造)

题目链接: C. Magic Odd Square Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. Input The only line contains odd integer n (1 ≤ n ≤ 49). Output Print n lines with n integers. All the

hdu1518(Square)深搜+剪枝

点击打开杭电1518 Problem Description Given a set of sticks of various lengths, is it possible to join them end-to-end to form a square? Input The first line of input contains N, the number of test cases. Each test case begins with an integer 4 <= M <= 20,

poj 1084 Square Destroyer dlx解重复覆盖

分析: 将问题转化为重复覆盖问题,DancingLink解决. 代码: //poj 1084 //sep9 #include <iostream> using namespace std; const int maxN=10024; const int maxL=128; int L[maxN],R[maxN],U[maxN],D[maxN]; int C[maxN],H[maxN]; int S[maxN],A[maxN],X[maxN]; bool makeup[maxL][maxL];

杭电 1518 Square (深搜)(回溯)

http://acm.hdu.edu.cn/showproblem.php?pid=1518 Square Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8343    Accepted Submission(s): 2706 Problem Description Given a set of sticks of various