蓝桥杯 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 ...
随机推荐
- 2019-9-16 java上课知识整理总结(动手动脑,课后实验)
java上课知识整理总结(动手动脑,课后实验) 一,课堂测试 1,题目:课堂测试:像二柱子那样,花二十分钟写一个能自动生成30道小学四则运算题目的 “软件” 要求:(1)题目避免重复: (2)可定制( ...
- npm - 换淘宝源
npm - 换淘宝源Node 的模块管理器 npm 会一起安装好.由于 Node 的官方模块仓库网速太慢,模块仓库需要切换到阿里的源. $ npm config set registry https: ...
- ng-options用法详解
ng-options属性可以在表达式中使用数组或对象来自动生成一个select中的option列表.ng-options与ng-repeat很相似,很多时候可以用ng-repeat来代替ng-opti ...
- cf 760B.Frodo and pillows
二分,判断条件就是最小情况(设当前k位取x)比剩余值(m-x)要小.(貌似又做麻烦了2333) #include<bits/stdc++.h> #define LL long long # ...
- 关于torch.norm函数的笔记
先看一下它的参数: norm(p='fro', dim=None, keepdim=False, dtype=None) p: the order of norm. 一般来说指定 $p = 1, 2$ ...
- tensorflow应用于手写数字识别(第二版)
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data#载入数据集 mnist = inp ...
- Tensorflow Mask-RCNN(三)——实时 检测视频
参考:https://www.youtube.com/watch?v=lLM8oAsi32g import cv2 import numpy as np def ran ...
- h5-任意元素居中
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- VUE- 访问服务器端数据 Vue-resource
VUE- 访问服务器端数据 Vue-resource 1. 安装 vue-resource cnpm install vue-resource --save 安装完毕后,在main.js中导入,如下所 ...
- A - Shortest path of the king (棋盘)
The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, becaus ...