玲珑杯 1137 - Sin your life(数学)
2024-09-01 07:33:25
题目链接: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;
}
最新文章
- LeetCode 345. Reverse Vowels of a String
- python---filecmp
- xcode 自定义Eclipse里边常用的快捷键
- 学习笔记(一)——MVC扩展
- thinkphp空控制器的处理
- iOS 时间戳
- Android自动检测版本及自动升级
- c++11 内存模型解读
- API 版本控制
- CSS3写常用的形状
- Runtime.exec()
- Asp.Net--回调技术
- JS如何判断IE和火狐与Chrome浏览器
- UNIX/Linux-进程控制(实例入门篇)
- 开启和禁用Wifi热点命令
- HDU-1275-两车追及或相遇问题(数学题目)
- 集群RPC通信
- Python 入门:基本语法
- Java基础系列--ArrayList集合
- week6:个人博客作业
热门文章
- 安装使用xen虚拟化工具
- 为什么for循环可以遍历list:Python中迭代器与生成器
- C++ protobuffer 前后端通信 简单应用
- python3 编译安装
- 【React踩坑记一】React项目中禁用浏览器双击选中文字的功能
- 如何让传统ASP.NET网站在Docker中运行
- [Spring cloud 一步步实现广告系统] 15. 使用开源组件监听Binlog 实现增量索引准备
- maven3实战之仓库
- 趣味CSS3效果挑战小汇总
- fatal: remote origin already exists.解决方法