Ural 1149 - Sinus Dances
Let Sn = (…(A1+n)A2+n–1)A3+…+2)An+1
For given N print SN
Input
Output
Sample
| input | output |
|---|---|
3 |
((sin(1)+3)sin(1–sin(2))+2)sin(1–sin(2+sin(3)))+1 |
Problem Source: Ural Collegiate Programming Contest, April 2001, Perm, Test Round
// Ural Problem 1149. Sinus Dances
// Verdict: Accepted
// Submission Date: 15:58:23 15 Jan 2014
// Run Time: 0.093s
//
// 版权所有(C)acutus (mail: acutus@126.com)
// 博客地址:http://www.cnblogs.com/acutus/// [解题方法]
// 简单字符串处理
// 注意:所有符号之间没有空格 #include<stdio.h> void An(int n)
{
int i;
for(i = ; i < n; i++) {
printf("sin(%d", i);
if(i%) printf("-");
else printf("+");
}
printf("sin(%d", n);
for(i = ; i <= n; i++) {
printf(")");
}
} void Sn(int n)
{
int i;
for(i = ; i < n; i++) {
printf("(");
}
for(i = ; i < n; i++) {
An(i);
printf("+%d)", n - i + );
}
An(n);
printf("+1\n");
} void solve()
{
int N;
scanf("%d", &N);
Sn(N);
} int main()
{
solve();
return ;
}
Ural 1149 - Sinus Dances的更多相关文章
- 模拟 URAL 1149 Sinus Dances
题目传送门 /* 模拟:找到规律分别输出就可以了,简单但是蛮有意思的 */ #include <cstdio> #include <algorithm> #include &l ...
- Timus 1149. Sinus Dances 打印复杂公式
就是打印以下这两个复杂的式子: Let An = sin(1–sin(2+sin(3–sin(4+-sin(n))-) Let Sn = (-(A1+n)A2+n–1)A3+-+2)An+1 For ...
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- ural 2069. Hard Rock
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...
- ural 2068. Game of Nuts
2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...
- ural 2067. Friends and Berries
2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...
随机推荐
- Eclipse+ADT的环境搭建
Index: . Java环境变量的设置 . Android环境变量的设置 1.Java环境变量的设置 A.属性名称:JAVA_HOME 属性值:C:\Program Files\Java\jdk1. ...
- Linux下nc命来实现文件传输
发送端:cat test.txt | nc -l -p 6666或者nc -l -p 6666 < test.txt 有些版本不要在 -p[监听6666端口,等待连接](设发送端IP为10.20 ...
- 转: js中的getYear()函数的问题(推荐用 getFullYear())
用了JS的getYear()方法,但是发现生成的代码竟然有108(本应该是2008),发现这是firefox下的问题. 然后google了一下,发 现原来是这样的:var today = new da ...
- C++模板:二分查找
bool find(int x,int l,int r){ if(l>r)return false; int mid=(l+r)/2; if(s[mid]==x) return true; el ...
- UVa 10131: Is Bigger Smarter?
动态规划题.类似UVa103 Stacking Box,都是题目给一种判断嵌套的方法然后求最长序列.提前对数据排序可以节省一些时间开销. 我的解题代码如下: #include <iostream ...
- linux目录对照命令——meld
preface:也不算是非常大的事情,但也须要这么个东西.对照两个目录里的内容是否同样,知道差异在哪里.找出问题所在,vimdiff 仅仅能比較两个文件是否同样,比較不了目录,只是能够写个bash脚本 ...
- Cramfs、JFFS2、YAFFS2的全面对比
Cramfs.JFFS2.YAFFS2的全面对比http://blog.csdn.net/daofengdeba/article/details/7721340 由于嵌入式系统自身存在一些特殊要求,使 ...
- BZOJ 2748 音量调节
这道题我开始做时想用搜索来做,但是失败了,后来仔细一想发现这就是一个背包问题,之后一切就简单多了. 代码如下: #include<cstdio> #includ ...
- 如何隐藏DLL中,导出函数的名称?
一.引言 很多时候,我们写了一个Dll,不希望别人通过DLL查看工具,看到我们的导出函数名称.可以通过以下步骤实现: 1. 在def函数中做如下定义: LIBRARY EXPORTS HideFunc ...
- [LeetCode]题解(python):029-Divide Two Integers
题目来源: https://leetcode.com/problems/divide-two-integers/ 题意分析: 不用乘法,除法和mod运算来实现一个除法.如果数值超过了int类型那么返回 ...