hdoj 1012 u Calculate e

HDOJ(递归)——1012.u Calculate e Problem Description A simple mathematical formula for e is where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n. Output Ou... 阅读详情

http://acm.hdu.edu.cn/showproblem.php?pid=1012

u Calculate e

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 31492    Accepted Submission(s): 14082


Problem Description
A simple mathematical formula for e is



where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.
 


 

Output
Output the approximations of e generated by the above formula for the values of n from 0 to 9. The beginning of your output should appear similar to that shown below.
 


 

Sample Output
  
n e - ----------- 0 1 1 2 2 2.5 3 2.666666667 4 2.708333333
 

 

#include<stdio.h>
#include<string.h>
#define N 10
int main()
{
	double a[100],b[100];
	int i,j,k;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	for(i=1,a[0]=1,b[0]=1;i<=N;i++)
	{//把结果放到b[]中 
	    a[i]=a[i-1]*i;
	    b[i]=b[i-1]+1.0/a[i];
	   // printf("%.0lf %lf\n",a[i],b[i]);
	}
	printf("n e\n");
	printf("- -----------\n");
	for(i=0;i<=1;i++)
	printf("%d %.0lf\n",i,b[i]);
	printf("%d %.1lf\n",i,b[i]);
	i+=1;
	for(;i<N;i++)
	printf("%d %.9lf\n",i,b[i]);
	
	return 0;
}
	
	

//注意double型的数据不能放在for(;;)里。

ISO 15118-3协议栈开发避坑指南:从EvseSlac状态机设计看电动汽车充电握手难题 本文深入剖析了ISO 15118-3协议栈开发中的核心挑战,特别是SLAC握手流程的实现难点。以Everest项目的EvseSlac状态机为例,详细解读了从状态机设计、多厂商PLC芯片兼容性处理,到严苛的时序与超时控制等关键工程实践,为开发者提供了一套超越协议文档的、可直接落地的避坑指南和软件实现方案。 阅读详情

相关推荐

Gartner《构建可扩展数据产品建设框架》心得

数据产品化:从概念到落地的实践指南 当前企业正从传统数据需求模式转向数据产品化新范式。本文系统阐述了数据产品的核心价值、定义分类和实施框架,指出成功关键是将数据包装为可复用、可扩展的产品。Gartner框架强调产品思维,提出4阶段12步实施路径,涵盖设计、工程、发布和监控全流程。文章特别提醒要避免7大常见误区,如简单重命名报表、忽视元数据治理等,建议采取MVP策略,90天内完成从价值验证到产品落地的闭环。实施中需平衡技术选型与业务需求,建立跨职能团队,并通过AARRR模型持续追踪产品价值。

2501_91410404的博客 1011

HDOJ1012 u Calculate e

HDOJ1013 题目 代码 #include<stdio.h> int main() { int n, i; double e = 0.0; int item = 1; printf("n e\n"); printf("- -----------\n"); printf("0 1\n"); printf("1 2\n"); printf("2 2.5\...

hfut橘生淮南的博客 205

Lattice CrosslinkNx LIFCL-40实战解析:MIPI D-PHY硬核IP配置与CSI-2数据解析全流程

本文详细解析了Lattice CrosslinkNx LIFCL-40 FPGA中MIPI D-PHY硬核IP的配置与CSI-2数据解析全流程。通过实战案例,介绍了硬件环境搭建、寄存器配置、数据包结构解析及视频流重构技巧,帮助开发者快速掌握高速图像采集系统的设计与优化方法。

weixin_29159613的博客 207

HDOJ 1012 u Calculate e

来源:http://acm.hdu.edu.cn/showproblem.php?pid=1012 u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 25914    Accepted Submissi

MummyDing's Blog 826

Cocos Creator 3D音频定位实战:从原理到沉浸感实现

3D音频定位是游戏开发中实现沉浸感的关键技术,其核心原理基于HRTF(头部相关传输函数)模型,模拟声音在空间中的传播与双耳感知差异。这项技术通过赋予声音空间坐标、距离衰减和方向属性,将音频从背景元素提升为可交互的环境线索,极大增强了虚拟世界的真实感与玩家的空间认知。在工程实践中,开发者需要深入理解声源、听者、衰减曲线与多普勒效应等基础概念,并合理运用音频池、优先级管理与动态混音等技术手段来平衡效果与性能。对于Cocos Creator开发者而言,无论是使用引擎原生的AudioSource组件构建轻量级方案,

weixin_30972263的博客 301

最适合入门的100个深度学习项目

本专栏整理了《PyTorch深度学习项目实战100例》,内包含了各种不同的深度学习项目,包含项目原理以及源码,每一个项目实例都附带有完整的代码+数据集。

CSDN 精品推荐 12万+

【hdoj】 1012 u Calculate e

u Calculate e **Problem Description A simple mathematical formula for e is where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values...

斌淇淋 183

【AI智能体】基于OpenCode 搭建Skills环境与项目实战开发详解

基于OpenCode 搭建Skills环境与项目实战开发详解

congge 8914

【HDOJ】【1012】u Calculate e

这次代码质量不高,对于前几个情况直接打印,显得比较low。从n==3开始,进行的计算。 #include #include /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char

师大一棵草的专栏 381

2026年瑞芯微数字IC设计笔试试卷带答案

本文主要考察数字集成电路设计相关知识,包括低功耗设计、时序分析、跨时钟域处理、总线协议等内容。试题分为单选题、多选题、代码设计题和简答题四部分。 单选题涉及门控时钟降低动态功耗、静态时序分析的限制、跨时钟域同步方案、时序违例修复方法、AHB总线信号、异步FIFO设计、半导体工艺电阻特性、二进制数转换、同步/异步复位比较以及分频电路设计等知识点。 多选题重点考查动态功耗优化技术、亚稳态特性、异步FIFO设计规范、Verilog可综合代码编写要求以及AXI总线协议特点等。 代码设计题要求实现一个同步FIFO和3

Open 224

Windows 11 安装 MySQL 8.4:安装包方式、下载、安装、使用

本文详细介绍了在 Windows 11 系统下通过 MSI 安装包方式安装 MySQL 8.4 LTS 社区版的完整流程,包括版本选择、下载、自定义安装路径、服务配置、日志设置、示例数据库创建及后续使用方法。同时提供了命令行客户端与图形化工具 DBeaver 的连接与操作演示,适合初学者和开发者快速搭建本地 MySQL 开发环境。

寒水馨 · 轻量级技术文档 · hanshuixin.org 2283

(HDOJ 1012)u Calculate e

u Calculate eProblem DescriptionA simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values...

aeg84268的博客 95

5G/NR 网络切片基本概念(协议版)

26.1 网络切片概念 网络切片是一个概念,可以根据每个客户的要求进行区别对待。通过切片的形式,将不同流量差异化处理,以及可以将资源进行隔离,然后移动网络运营商可以将客户视为属于不同租户类型的客户,每种客户具有不同的服务要求,这些要求根据每个租户根据SLA (Service Level Agreement,服务水平协议)可以使用哪种切片类型进行管理和订阅。 网络切片始终由RAN部分和CN部...

欢迎来到小七的博客,这里将带你深入探索5G通信的神秘世界。无论你是通信领域的专业人士还是对这一领域充满好奇心的技术爱好者,这里都有专业协议解读、通信知识普及以及有趣的Python编程内容等你发现。 1万+

HDOJ 1012 u Calculate e解题报告

#include #include using namespace std; int func(int n) { int sum = 1; for(int i = 1;i

冰枫的随笔 1614

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

HDOJ 1012 u Calculate e 解题报告

u Calculate e Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 23177Accepted Submission(s): 10216 Problem Description A simple mathem...

aian53516的博客 159

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

HDOJ HDU 1012 u Calculate e

HDOJ 1011 u Calculate e题目 点此查看 HDOJ 1011 u Calculate e 题意 按给出的图片公式 按公式计算阶e 题解 打表阶乘 打表 e 输出即可 表 n e - ———– 0 1 1 2 2 2.5 3 2.666666667 4 2.708333333 5 2.716666

Gy_1096440940的博客 406

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

HDOJ 1012 u Calculate e

u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 29875    Accepted Submission(s): 13312 Problem Description A simple m

淡定的小鱼 806

HDOJ 1012 u Calculate e

u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 24567    Accepted Submission(s): 10905 Problem Description A simple m

哇咔咔的升级之路~ 588

hdoj1012--u Calculate e

Problem Description A simple mathematical formula for e is where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.

Code for ACM 663
上一篇: hdoj 5011 Game(基础尼姆博弈)
下一篇: nyoj 67 三角形面积
SimonCoder
博客等级 码龄13年 1413粉丝 231原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址