poj 2413 How many Fibs?

HHD Device Monitoring Studio:破解版在串口调试中的实战应用 本文详细介绍了HHD Device Monitoring Studio破解版在串口调试中的实战应用,包括安装指南、串口监控功能解析、Modbus RTU协议分析案例以及自定义协议解析技巧。通过具体操作步骤和性能优化建议,帮助开发者高效完成端口监控和调试任务,提升工作效率。 阅读详情

How many Fibs?
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 10748 Accepted: 3982

Description

Recall the definition of the Fibonacci numbers: 
f1 := 1 

f2 := 2 

fn := fn-1 + fn-2     (n>=3) 

Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a,b].

Input

The input contains several test cases. Each test case consists of two non-negative integer numbers a and b. Input is terminated by a=b=0. Otherwise, a<=b<=10100. The numbers a and b are given with no superfluous leading zeros.

Output

For each test case output on a single line the number of Fibonacci numbers fi with a<=fi<=b.

Sample Input

10 100
1234567890 9876543210
0 0

Sample Output

5
4

解题思路:

用一个字符串数组记录位数小于101的所有fibs,然后对于给定的a,b,求出满足条件的个数;

#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
char fibs[10005][102];
void add(int n){
	int len_a=strlen(fibs[n-1]),len_b=strlen(fibs[n-2]);
	int p=len_a-1,q=len_b-1;
	int a[102],left=0;
	for (int i=0;i<102;i++){
		a[i]=left;
		if (p>=0)
			a[i]+=fibs[n-1][p--]-'0';
		if (q>=0)
			a[i]+=fibs[n-2][q--]-'0';
		left=a[i]/10;
		a[i]%=10;
	}
	int i;
	for (i=101;i>=0;i--){
		if (a[i]!=0)
			break;
	}
	int k=0;
	while (i>=0){
		fibs[n][k++]=a[i--]+'0';
	}
	fibs[n][k]=0;
}
bool cmp(char *a,char *b){
	int len_a=strlen(a),len_b=strlen(b);
	if (len_a>len_b)
		return true;
	if (len_a<len_b)
		return false;
	int n=0;
	while (n<len_a){
		if (a[n]-'0'>b[n]-'0')
			return true;
		if (a[n]-'0'<b[n]-'0')
			return false;
		n++;
	}
	return true;
}
int main(){
	strcpy(fibs[0],"1");
	strcpy(fibs[1],"2");
	int k=1;
	while (strlen(fibs[k++])<101){
		add(k);
	}
	char a[102],b[102];
	while(scanf("%s %s",a,b),strcmp(a,"0")!=0||strcmp(b,"0")!=0){
		int count=0;
		for (int i=0;i<=k;i++){
			if (cmp(fibs[i],a)==false)
				continue;
			if (cmp(fibs[i],a)==true && cmp(b,fibs[i])==true)
				count++;
			if (cmp(b,fibs[i])==false)
				break;
		}
		cout<<count<<endl;
	}
	return 0;
}




FC7300 SPI MCAL配置引导 Example - QMI8A01z外设:Example - QMI8A01z外设: 阅读详情

相关推荐

FPGA人脸识别检测(先获取人脸图像以及灰度二值化)

由于图片有空洞等缺陷,所以后面要进行中值滤波、腐蚀、膨胀等算法处理,然后再对人脸进行框选,最后显示出来。最终的成像应该是下面这样的。(后面有时间再接着做哈哈哈)5、通过modelsim将操作后的图片数据写入gray_img.txt里面后,用matlab将txt转成图片。1、先用matlab将图片转换成txt数据,代码如下。读取图片的方式按照博客咸鱼里的方式来做,如下。2、FPGA读取txt数据。4、FPGA顶层模块及仿真。3、FPGA灰度二值化。

weixin_46312715的博客 2531

http://poj.org/problem?id=2413

How many Fibs? Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10543   Accepted: 3910 Description Recall the definition of the Fibonacci numbers:  f1 := 1

yishenpingan的专栏 900

【板栗糖GIS】新装ArcGIS必调的12个隐藏设置——【效率翻倍指南】

本文详细介绍了新装ArcGIS后必调的12个隐藏设置,涵盖性能优化、路径管理、显示调校、工作流定制等方面,帮助用户显著提升GIS工作效率。从关闭后台地理处理到启用硬件加速,再到个性化快捷键配置,这些实用技巧能让ArcGIS运行更流畅,操作更便捷。

weixin_42524945的博客 544

HDU1316-How Many Fibs?(斐波拉契数的个数,大数计算)

Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := fn-1 + fn-2 (n >= 3) Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a, b]. Input The input contains several test cases. Each test case consists of t

weixin_43357583的博客 209

UDS诊断入门第一课:手把手教你玩转0x10会话控制服务(附ISO14229实战解析)

刚接触汽车电子诊断的工程师们,往往会被厚厚的ISO 14229标准文档和各种专业术语吓退。但就像学习编程要从"Hello World"开始一样,掌握UDS协议的最佳切入点就是0x10诊断会话控制服务。这个看似简单的服务,实际上是整个诊断系统的"钥匙"——它决定了ECU(电子控制单元)当前处于何种工作模式,直接影响着其他诊断服务的可用性。 在实际车辆诊断中,ECU默认处于DefaultSession模式,这种模式下许多高级诊断功能是被禁用的。想象一下你正在开发一个需要刷写ECU固件的工具,如果连最基本的会

weixin_30402343的博客 392

期货套利策略(二)

接上一篇期货套利策略,随着对期货套利策略的深入了解,我发现套利策略不是那么好做的。下面将会讲碰到的一些问题。 上一篇文章中没有考虑滑点的问题,这里我们把滑点问题考虑进去。这里先说一些天勤api的买入点,天琴的买入点是当前K线的收盘价。碰到数据传输问题,还有计算等各方面问题,实际情况是无法在当前K线的收盘价买入的。这里我们把这方面问题考虑进去,利用api.wait_update()调到下一个k线数据...

qq_31611005的博客 1711

大数斐波那契比较 杭电1316 JAVA

Problem Description Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := fn-1 + fn-2 (n >= 3) Given two numbers a and b, calculate how many Fibonacci numbers are in the ran

a907607222的专栏 773

使用rknn进行facenet部署

修改facenet网络的forward函数代码。

如果想成为中心,那么就到中心去吧。 1044

java 大数_Java 大数

How Many Fibs?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6641 Accepted Submission(s): 2629Problem DescriptionRecall the definition of th...

weixin_39638526的博客 144

使用 vLLM 和 YaRN 扩展技术部署 Qwen3-32B 大模型:实现 80K 长文本推理

vLLM 是一个高性能的 LLM 推理和服务引擎,以其高效的注意力机制(PagedAttention)和优异的内存管理著称。它提供了与 OpenAI API 兼容的接口,使得现有应用可以无缝迁移。通过vLLM与YaRN技术的结合,我们成功将Qwen3-32B的上下文处理能力从32K扩展到80K,为长文本应用场景提供了强大的技术支持。这种部署方案兼具高效性和实用性,是处理大模型长上下文需求的优选方案。随着硬件和算法的不断进步,我们期待看到更大上下文窗口的模型服务成为可能。延伸阅读vLLM官方文档。

Ven%的博客 1748

194、产线 Camera 校准与测试:终检测试项、规格线制定与量产数据监控

摘要: 文章通过"绿屏门"案例揭示了产线Camera校准测试中的关键问题,提出了系统性改进方案。在终检测试方面,建议增加多增益暗电流测试、混合光源色温测试和径向亮度梯度测试,覆盖用户真实场景。规格线制定强调用CPK替代固定百分比,区分硬软规格并建立动态调整机制。量产监控需关注参数趋势、边界模组分布,构建失效模式数据库。实践建议包括测试冗余设计、规格余量预留、自动化监控、供应商数据共享和人工抽检保留。文章指出Camera产线质量管控需形成"测试设计-规格优化-数据监控"闭环,以数据驱动决策避免客诉风险。

sundong_81的博客 191

POJ2413 How many Fibs(高精度)(AC)

How many Fibs? Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11896   Accepted: 4312 Description Recall the definition of the Fibonacci numbers:  f1 := 1

twinslizzy的博客 474

DeepSeek 赋能招投标全流程智能化:多模态解析、知识图谱与投标文件自动生成实战指南(附完整代码与行业案例)

摘要:本文深入探讨DeepSeek技术在招投标领域的全流程智能化应用,通过整合自然语言处理(NLP)、多模态解析、知识图谱等核心技术,实现招标文件智能解析与投标文件自动生成。文中详细解析DeepSeek-R1模型的多模态处理机制、动态知识图谱构建方法及智能模板填充算法,通过完整代码实现展示技术细节。结合广某资源交易平台、山西XX"XX云"等典型案例,验证技术方案在提升招投标效率、降低人为错误方面的显著效果。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 1462

POJ 2413 How many Fibs? /HDOJ 1316 How Many Fibs?

题目来源:http://poj.org/problem?id=2413 /  http://acm.hdu.edu.cn/showproblem.php?pid=1316 How many Fibs? Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10742

MummyDing's Blog 1210

深度学习工具包 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")

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

POJ2413 ZOJ1962 How many Fibs

//4_7_31: How many Fibs 区间内的Fibonacci数的个数 POJ2413 ZOJ1962 //计算得出Fibonacci数到10^100的时候具有475位 #include #include #include using namespace std; short F1[120],F2[120],ans[120]; char Fib[500][120]; int s

346

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

POJ 2413 How many Fibs?

How many Fibs? Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10081   Accepted: 3733 Description Recall the definition of the Fibona

公众号:ByteCode 921

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

POJ 2413 How many Fibs? .

题目地址:http://poj.org/problem?id=2413 import java.util.*; import java.math.*; import java.text.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner cin = new S

BRCOCOLI的博客 350

POJ2413 How many Fibs?【高精度】【二分】

题目大意: 定义fibonacci数列前两项f[1] = 1,f[2] = 2。现在给你一个区间[a,b],a <= b <= 10^100。 问:区间[a,b]之间有多少个fibonacci数。 思路: a、b的规模很大,是个100位10进制的数。所以要用数组模拟大整数加法求fibonacci数列。用整型 二维数组F[i][]表示第i个fibonacci数,因为从个位倒着存入数组方便进位,所以F[i][]数组中的数是倒 着的。第480个fibonacci数是101位,先求出前480个fibonacci数

程序员充电站(itcharge) 1485

POJ 2413 How many Fibs? 笔记

已知a,b。求区间[a,b]之间的斐波那契数个数。 

woniupengpeng的专栏 304

How many Fibs?(poj 2413)大数斐波那契的问题

http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=259#problem/C Description Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := fn-1 + fn-2 (n >= 3) Given two numbers a and b, calculate how many Fibonacci numbers are in the ra

wangjunjie_123的博客 248

POJ 2413 How many Fibs?

大数区间Fibonacci数的个数 const int maxn = 9999 ; // 每位储存4位 const int dig = 4 ; class BigNum{ public : int a[60] ; int len ; BigNum(){len = 1 ; memset(a , 0 , sizeof(a)) ;}

老李2009 579

How many Fibs?(poj 2413)大数斐波那契

http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=259#problem/CDescription Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := fn-1 + ...

weixin_26833503的博客 166

POJ 2413 How many Fibs? (java大数)

How many Fibs? Description Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := f n-1 + f n-2 (n>=3) Given two numbers a and b, calculate how many Fibon...

dexicuo5991的博客 159

poj 2413 java How many Fibs?

<br /> <br />高精度题,java水过~<br /> <br />需要注意的是<br />0 1<br />0 2<br />1 2<br />2 3<br />这几个输入<br /> <br />}import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner cin=new Scanner(Syste

蛰伏神兽的专栏 827

HDU1316 POJ2413 UVA10183 ZOJ1962 How Many Fibs?【大数】

How Many Fibs? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8526 Accepted Submission(s): 3286 Problem Description Recall the definition o...

海岛Blog 566
上一篇: poj 3331 The Idiot of the Year Contest!
下一篇: poj 3233 Matrix Power Series
JinbaoSite0144
博客等级 码龄12年 231粉丝 157原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值