蓝桥杯 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 ...
随机推荐
- Discuz中常用的编辑器代码
.[ b]文字:在文字的位置可以任意加入您需要的字符,显示为粗体效果. .[ i]文字:在文字的位置可以任意加入您需要的字符,显示为斜体效果. .[ u]文字:在文字的位置可以任意加入您需要的字符,显 ...
- CTF-域渗透--靶场夺旗
开门见山 1. 扫描靶场ip 192.168.1.106 2. 扫描靶场开放端口 3. 扫描靶场全部信息 4. 探测靶场敏感信息 5. 对一些特殊的端口进行nc探测 6. 为了绕过对应命令执行限制,可 ...
- Python 中 使用 HTMLTestRunner 模块生成测试报告
使用 HTMLTestRunner 模块可以生成测试报告,但是系统自带的报告不详细,不好看,所以找了一份详细的报告 HTMLTestRunner 模板,直接导入就能使用 两种方法生成HTML报告,都 ...
- web.xml中filter加载顺序出现的问题
刚刚遇到了一个问题,项目中需要用到characterEncodingFilter和HiddenHttpMethodFilter,但是post请求还是会中文乱码,找了半天原因,后来发现,filter加载 ...
- ETL工具对比
ETL工具对比 Informatica Kettle 起源 1993年创立于 (美国加利福尼亚州)并于1999年4月在纳斯达克上市 2006年加入了开源BI组织 自2017年9月起,已被(日立集团下 ...
- Tensorflow——用openpose进行人体骨骼检测
https://blog.csdn.net/eereere/article/details/80176007 参考资料code:https://github.com/ildoonet/tf-pose- ...
- lambda的题
def num(): return [lambda x: i*x for i in range(4)] print([m(2) for m in num()]) 这个式子,lambda相当于闭包函数, ...
- Navicat mysql 数据库备份和使用,备份以后是nb3文件
通过Navicat进行Mysql数据库自动备份与还原 Mysql数据库自动备份流程 Navicat版本为:Navicat 12.0.26 例:test为用于测试自动备份的数据库,里面有表t_per ...
- delphi内嵌汇编
{ 前面知道了一个汇编的赋值指令(MOV), 再了解一个加法指令(ADD), 就可以做个例子了. 譬如: ADD AX,BX; 这相当于 Delphi 中的 AX := AX + BX; 另外提前来个 ...
- 动态加载JS文件方法总结
1.JQuery方法 $.getScript("./test.js"); //加载js文件 $.getScript("./test.js",function() ...