题目链接:http://www.ifrog.cc/acm/problem/1137

 

题解:设m=n-z

sin(x)+sin(y)=sin(m-y)+sin(y)利用公式得最大值为sqrt(sin(m)*sin(m)+(1-cos(m))*(1-cos(m)))

所以只要便利一下z就可以了。

#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#define Pi acos(-1)
using namespace std;

int main() {
    int n;
    scanf("%d" , &n);
    double ans = 0 , Max = -3;
    for(int i = 1 ; i <= n ; i++) {
        int z = i;
        int m = n - z;
        Max = max(Max , sin(1.0 * z) + 1.0 * sqrt(sin(1.0 * m) * sin(1.0 * m) + (1.0 - cos(1.0 * m)) * (1.0 - cos(1.0 * m))));
    }
    printf("%.9lf\n" , Max);
    return 0;
}

相关文章:

  • 2021-07-02
  • 2021-10-21
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
相关资源
相似解决方案