蓝桥杯 sine之舞(递归)
Description
不妨设
An=sin(1–sin(2+sin(3–sin(4+...sin(n))...)
Sn=(...(A1+n)A2+n-1)A3+...+2)An+1
FJ想让奶牛们计算Sn的值,请你帮助FJ打印出Sn的完整表达式,以方便奶牛们做题。
Input
Output
Sample Input
3
Sample Output
((sin(1)+3)sin(1–sin(2))+2)sin(1–sin(2+sin(3)))+1
就一道简单递归,写两个递归函数AN,SN就行了
不过改了一晚上,被这个减号坑惨了,"-"和"—"都不是题中的这个符号"–"
无语。。。。。。。
以后遇到符号一律复制,绝不手打
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
const int INF=0x3f3f3f3f;
typedef long long LL;
const int mod=1e9+;
//const double PI=acos(-1);
#define Bug cout<<"---------------------"<<endl
const int maxm=1e6+;
const int maxn=1e5+;
using namespace std; void PTA(int t,int n)//输出AN
{
if(t>n)
return ;
printf("sin(%d",t);
if(t!=n)
{
if(t%)
printf("–");
else
printf("+");
}
PTA(t+,n);
printf(")");
} void PTS(int t,int n)//输出SN
{
if(t<)
return ;
if(t!=)
printf("(");
PTS(t-,n);
if(t!=)
printf(")");
PTA(,t);
printf("+%d",n+-t);
} int main()
{
int n;
scanf("%d",&n);
PTS(n,n);
return ;
}
差不多的:
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
const int INF=0x3f3f3f3f;
typedef long long LL;
const int mod=1e9+;
//const double PI=acos(-1);
#define Bug cout<<"---------------------"<<endl
const int maxm=1e6+;
const int maxn=1e5+;
using namespace std; void PTA(int t,int n)
{
if(t==n)
{
printf("sin(%d)",t);
return ;
}
printf("sin(%d",t);
if(t%)
printf("–");
else
printf("+");
PTA(t+,n);
printf(")");
} void PTS(int t,int n)
{
if(t==n)
{
PTA(,);
printf("+%d",t);
return ;
}
else
{
printf("(");
PTS(t+,n);
printf(")");
PTA(,n-t+);
printf("+%d",t);
}
} int main()
{
int n;
scanf("%d",&n);
PTS(,n);
printf("\n");
return ;
}
蓝桥杯 sine之舞(递归)的更多相关文章
- 蓝桥杯—BASIC-21 sine之舞(递归递推)
题目:最近FJ为他的奶牛们开设了数学分析课,FJ知道若要学好这门课,必须有一个好的三角函数,所以他准备和奶牛们做一个“Sine之舞”的游戏,寓教于乐,提高奶牛们的计算能力. 不妨设 An=sin(1– ...
- BASIC-21_蓝桥杯_Sine之舞
思路: 先根据例子找出规律,列出递归要打印的数据; 示例代码: #include <stdio.h> int n = 0; void dg(int x){ int i = 0; if (x ...
- Java实现 蓝桥杯 算法训练 递归求二项式系数
算法训练 6-1 递归求二项式系数值 时间限制:10.0s 内存限制:256.0MB 问题描述 样例输入 一个满足题目要求的输入范例. 3 10 样例输出 与上面的样例输入对应的输出. 数据规模和约定 ...
- Java实现 蓝桥杯VIP 基础练习 Sine之舞
问题描述 最近FJ为他的奶牛们开设了数学分析课,FJ知道若要学好这门课,必须有一个好的三角函数基本功.所以他准备和奶牛们做一个"Sine之舞"的游戏,寓教于乐,提高奶牛们的计算能力 ...
- 蓝桥杯练习系统—基础练习 sine之舞
题目:最近FJ为他的奶牛们开设了数学分析课,FJ知道若要学好这门课,必须有一个好的三角函数,所以他准备和奶牛们做一个"Sine之舞"的游戏,寓教于乐,提高奶牛们的计算能力. 不妨设 ...
- [蓝桥杯][基础训练]Sine之舞
Description 最近FJ为它的奶牛开设了数学分析课,FJ知道,若要学好这门课,必须有一个好的三角函数基本功. 所以他为奶牛们做了一个“Sine之舞”的游戏,寓教于乐,提高奶牛的计算能力. 不妨 ...
- (acwing蓝桥杯c++AB组)1.1 递归
(acwing蓝桥杯c++AB组)1.课程介绍+递归 文章目录 (acwing蓝桥杯c++AB组)1.课程介绍+递归 课程介绍 第一讲 递归与递推 递归 引入 递归的底层调用顺序 例题与练习 课程介绍 ...
- 蓝桥杯_基础训练_Sine之舞
基础练习 Sine之舞 时间限制:1.0s 内存限制:512.0MB 问题描述 最近FJ为他的奶牛们开设了数学分析课,FJ知道若要学好这门课,必须有一个好的三角函数基本功.所以他准备和奶牛们做 ...
- sin之舞---蓝桥杯练习
问题描述 最近FJ为他的奶牛们开设了数学分析课,FJ知道若要学好这门课,必须有一个好的三角函数基本功.所以他准备和奶牛们做一个“Sine之舞”的游戏,寓教于乐,提高奶牛们的计算能力. 不妨设 An=s ...
随机推荐
- P 1034 有理数四则运算
转跳点:
- LARGE_INTEGER 64位的输出格式
%016I64x 第一个016是指当最左边无数据时用00填充:后面的I64x是__int64的前缀要求格式十六进制输出.
- Egret Engine 2D - 项目配置
todo 看三个示例项目的完整源码和资源 <e:Group name="Button" height = "300" verticalCent ...
- java String字符串判断
判断空字符串:StringUtils.isBlank StringUtils.isBlank(null) = true StringUtils.isBlank("") = true ...
- 在开发过程中遇到的Oracle的坑及开发技巧
本人与2018年毕业,工作一年多,仍是菜鸟,自毕业以来一直从事java软件开发工作,工作中大部分数据库都是使用的Oracle,碰到的问题总结一下(随时更新). 1.sql中使用group by 分组时 ...
- HttpServlet中文乱码问题
客户端提交数据给服务器端(Requset) 如果数据中带有中文的话,有可能会出现乱码情况,那么可以参照以下方法解决. 如果是GET方式 1.代码转码 String username = request ...
- Java基础——HashTable源码分析
HashTable是基于哈希表的Map接口的同步实现 HashTable中元素的key是唯一的,value值可重复 HashTable中元素的key和value不允许为null,如果遇到null,则返 ...
- WebServerInitializedEvent &ApplicationRunner
application.properties app.name=yaoyuan2 app.dept.id=1 MyConfig.java import lombok.AllArgsConstructo ...
- SQL inner join, join, left join, right join, full outer join
基本信息 创建两个表a1, a2. 两个表的重要差别是:a1 中有5,'wu',a2中没有. a2中有 4,'li',而a1中没有. 创建表和插入数据的代码如下: -- 创建a1表 create ta ...
- group_concat用法以及字符串太长显示不全
由于group_concat默认的长度是1024,所以要将最大长度修改 首先执行 SET SESSION group_concat_max_len = 10240;#一次查询有效 然后再进行拼接 se ...