Convex 一道阿姆斯特朗回旋好题

2001年5月8日,阿姆斯特朗(Armstrong, 1929-2013) 教授发明了一种名为“阿姆斯特朗回旋加速喷气式阿姆斯特朗加密”的加密算法,算法从未公开,直至2013阿姆斯特朗教授逝世后,其生前的研究手稿被其儿子小阿姆斯特朗(Xiaoarmstrong,1995-)发表后才得以被大众所知。一天,小阿姆斯特朗突然对阿姆斯特朗回旋加速喷气式阿姆斯特朗加密算法产生了兴趣,她决定研究一下这个阿姆斯特朗回旋加速喷气式阿姆斯特朗加密算法,但由于阿姆斯特朗回旋加速喷气式阿姆斯特朗加密算法十分复杂,于是小阿姆斯特朗决定今天只研究阿姆斯特朗回旋加速喷气式阿姆斯特朗加密算法的第一步。于是,她找来了一道acm训练题进行了阿姆斯特朗回旋加速喷气式阿姆斯特朗加密,在进行完阿姆斯特朗回旋加速喷气式阿姆斯特朗加密算法的第一步之后,这道题变成了下面这串数字:
 
1746953559 543520353 1886593121 1634296677 1868767340 2019915374 1634235424 1818304628 1869619308 1937010281 1986095136 1752440933 1634934885 1679844717 1635021673 543515502 1864396660 1768384882 1869619310 779382377 544424202 544567161 2003791467 543520544 544104803 544499047 1702043726 1852140903 1629516660 1919251558 1852402720 1735289195 1701344288 1769107232 544106855 1852403568 1851859060 1752440932 1869619301 1937010281 544108320 543516788 1986948963 539916389 1663067479 1629515361 544174956 544499047 1851859022 1936026727 1952801312 1852138871 1667327264 1634738280 1864397417 1752440934 1701716069 1651009385 1931506287 1701668709 779318382 2003783178 1986619168 1870209125 1752440949 1633951845 1629512052 1953853282 1701344288 1735287072 539780460 1634036848 1663067507 1969450081 1702125932 1701344288 1701994784 1718558817 1701344288 1852793632 779642230 1225394734 1414877262 1701336074 1629513074 1830839666 1769237621 543517808 1953719668 1935762208 170816357 543516756 1936877926 1768693876 1663067502 1635020399 544435817 544175988 1702129257 544367975 1851859022 541335652 1768189545 1769234787 1948280686 1847616872 1700949365 1718558834 1701344288 1768910880 544437358 543452769 1768253556 1768169586 1851880563 1948280163 1919885423 1852401513 858267694 540884000 1027350606 741355808 1008742688 541335613 824196412 1409952048 1847616872 544503909 1701734764 1868767347 1767994478 541991022 1702129257 1936876903 1684957472 1952539497 543649385 543516788 1818717793 539915109 543516756 544044403 1948280431 1310745960 1836412448 1936876898 544434464 1635216481 857764729 170799158 1414876938 173299024 544370502 1751343461 1936028704 1633886324 1864394099 1970304117 1852776564 1818632293 544498031 1651340654 544436837 1768189545 1769234787 1948280686 1629513064 543253874 1948280431 1663067496 1702260335 1411395192 1881171304 1953393010 1981834341 1702194273 1752375411 1684829551 1986095136 540221541 1768384868 1629516660 1919251558 1701344288 1667589152 1818324329 1768910880 170816622 0
 
现在,请你来做这道acm训练题,对阿姆斯特朗回旋加速喷气式阿姆斯特朗加密算法不了解的同学请看Hint。
Input

请看题目描述

Output

请看题目描述

Sample Input
4 1
90 90 90 90
6 1
60 60 60 60 60 60
Sample Output
2.000
2.598
Hint
关于阿姆斯特朗回旋加速喷气式阿姆斯特朗加密算法的第一步:
该算法首先读入一段文本,该文本的每个字符仅占1字节,直到结束。
然后,该算法会将连续的每4个字节的二进制位按逆序连接,凑成一个整数,并在末尾加0。例如:
读入:
abcdefgh
(二进制:01100001(a) 01100010(b) 01100011(c) 01100100(d) 01100101(e) 01100110(f) 01100111(g) 01101000(h))
转换后:
1684234849 1751606885 0
(二进制:01100100011000110110001001100001 01101000011001110110011001100101 0)
(01100100(d)01100011(c)01100010(b)01100001(a) 01101000(h)01100111(g)01100110(f)01100101(e) 0)
 
学长出的很有意思的一道题,特别简单。
 
翻译代码:
 
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;
int main()
{
    int t;
    while(cin>>t&&t != 0)
    {
        while(t)
        {
            putchar(t%256);
            t/=256;
        }
    }
}

翻译后题目为:

We have a special convex that all points have the same distance to origin point.
As you know we can get N segments after linking the origin point and the points on the convex. We can also get N angles between each pair of the neighbor segments.
Now give you the data about the angle, please calculate the area of the convex..

INPUT
There are multiple test cases.
The first line contains two integer N and D indicating the number of the points and their distance to origin. (3 <= N <= 10, 1 <= D <= 10)
The next lines contain N integers indicating the angles. The sum of the N numbers is always 360.

OUTPUT
For each test case output one float numbers indicating the area of the convex. The printed values should have 3 digits after the decimal point.

求三角形面积,用到公式s=0.5*a*b*sinc.

代码:

#include <bits/stdc++.h>
#define pi 3.1415926
using namespace std;
int main()
{
    double sum = 0,d;
    int n,de[10];
    while(cin>>n>>d){
    sum = 0;
    for(int  i = 0;i < n;i ++)
    {
        cin>>de[i];
        sum += 0.5*d*d*sin(de[i]*pi/180);
    }
    printf("%.3f
",sum);
    }
}
原文地址:https://www.cnblogs.com/8023spz/p/7786874.html