HDU 2802 F(N)

详解各类以太网标准10BASE-T/100BASE-T4/100BASE-FX/1000BASE-X等 以太网是现实世界中最普遍的一种计算机网络。以太网有两类:第一类是经典以太网,第二类是交换式以太网,使用了一种称为交换机的设备连接不同的计算机。经典以太网是以太网的原始形式,运行速度从3-10 Mbps不等;而交换式以太网正是广泛应用的以太网,可运行在100Mbps、1000Mbps和10000Mbps高速率,分别以快速以太网、千兆以太网和万兆以太网的形式呈现 阅读详情

F(N)

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3408    Accepted Submission(s): 1171


Problem Description

Giving the N, can you tell me the answer of F(N)?
 

Input
Each test case contains a single integer N(1<=N<=10^9). The input is terminated by a set starting with N = 0. This set should not be processed.
 

Output
For each test case, output on a line the value of the F(N)%2009.
 

Sample Input
  
1 2 3 0
 

Sample Output
  
1 7 20
 

Source
 

Recommend
lcy   |   We have carefully selected several similar problems for you:   2807  2803  2804  2800  2806 
 

Statistic |  Submit |  Discuss |  Note

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<stdlib.h>
using namespace std;
typedef long long LL;
const LL MOD = 2009;
LL f[4050];
void init()
{
    f[1] = 1; f[2] = 7;
    for(LL i = 3;i <= 4018;i++)
    {
        f[i] = (f[i-2]%MOD+(((i*i*i)%MOD-((i-1)*(i-1)*(i-1))%MOD)+MOD)%MOD)%MOD;
    }
}//4018是循环节 4018^3 = 64,867,893,832超int所以用long long
int main()
{
    init();
    int N;
    while(scanf("%d",&N)&&N)
    {
        N = N%4018;
        printf("%d\n",f[N]);
    }
    return 0;
}


基于ADMM的TV正则化最小化稀疏实现图像重建 ADMM算法是一种求解带有约束条件的优化问题的有效方法,它可以将原问题分解成两个子问题,然后交替求解这两个子问题,直到收敛。为了解决这些问题,研究人员提出了许多图像重建方法,其中一种常用的方法是基于正则化的方法。在图像重建中,TV正则化是一种比较常用的正则化方法,可以有效地降低图像的噪声,并保持图像细节特征。通过本文的介绍和源代码的演示,我们可以看出基于ADMM的TV正则化最小化稀疏实现图像重建的方法是一种简单、高效、有效的图像重建方法,能够在一定程度上提高图像质量,对于实际应用具有一定的参考意义。 阅读详情

相关推荐

做量化没有实时数据怎么行?我找到一个超级好用的Python库,速度还贼快!

今天咱们介绍了 pytdx 这个神奇的库,重点包括:✅ 安装 pytdx✅ 连接 TDX 服务器✅ 获取实时行情数据✅ 获取 K 线数据✅ 获取分笔成交数据总之,pytdx 是一个速度快、免费、易用的量化利器,适合 A 股量化交易的同学们使用。如果你还在为数据发愁,赶紧试试吧!🚀顺手再看就是对花姐最大的支持,期待你的关注。

奔跑的蜗牛 5726

HDU---2802

Description   Giving the N, can you tell me the answer of F(N)? Input Each test case contains a single integer N(1 Output For each test case, output on a line the value of th

qq_35030023的博客 300

STM32F103C8T6+HX711实战:从零打造智能体重秤(附OLED显示与语音播报)

本文详细介绍了基于STM32F103C8T6微控制器和HX711称重模块,从零构建智能体重秤的完整实战教程。内容涵盖硬件选型、系统架构、驱动编写、数据滤波校准算法,并实现了OLED显示与语音播报功能。该项目是嵌入式学习的综合性实践,尤其适合作为毕业设计课题,帮助开发者掌握传感器应用、数据处理及人机交互等核心技能。

weixin_28285943的博客 518

hdu2802:F(N)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2802 参考思路:通过变换,you

xiaobei1a2b3c的专栏 691

【学习笔记】人群归因分数 PAF 以及combined PAF(更新)

在此推荐2篇发表在lancet以及jama子刊上的paf文章,这两篇文章套路是一样的,只是在不同国家进行。希望对大家学习PAF有所帮助,后面有新内容也会继续分享,也欢迎大家分享使用R语言计算PAF的经验~~~的时候,先建立了相关矩阵,再做主成分分析,得到communality。详细信息大家可翻阅原文。

weixin_53499537的博客 1498

避坑指南:LVGL在Arduino环境编译报错?3步搞定lv_conf.h路径问题(附ST7789屏幕调试技巧)

本文详细解析了在Arduino环境中配置LVGL图形库时,如何解决常见的“lv_conf.h file not found”编译报错问题。通过三步法:定位并复制模板文件、启用核心配置并指定路径、配置基础参数,从根本上解决路径问题。文章还结合ST7789屏幕驱动,分享了使用TFT_eSPI库进行显示适配、内存优化及背光控制等实战调试技巧,帮助开发者建立清晰、可维护的嵌入式UI工程基础。

lake5的博客 860

HDOJ/HDU 2082 母函数 找单词 2006/1/15 ACM程序设计期末考试

找单词 Time Limit : 1000/1000ms (Java/Other)Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 4Accepted Submission(s) : 4 Font: Times New Roman | Verdana | Georgia Font Size: ← → Pro...

lilisalo 487

抖音用户主页视频数据爬虫详解(点赞,收藏,分享等)

的包中有个max_cursor参数,请求载荷中也有一个这样的参数,每次请求的数据中max_cursor是下一个请求的载荷,,,同时has_more为1时候代表还能请求,0为不能请求,我们做如下判断。最后发现cookie很容易过期,批量爬取有点困难,,,,我们采用drissoinpage进行自动化获取。首先进行抓包分析,,,随便找个主页,f12,关键词搜索,发现这个包是以post开头。请你第一次运行先按0,进行登录(或者触发反爬的时候),登录完成之后,按1进行爬取,完整代码请在知识星球。

m0_74823507的博客 3429

HDU-2802-F(N)

看到这题讨论版里有说用公式的有说用循环节的,但是个人觉得这两种方法都不靠谱,比赛场上做这种题能直接推出公式需要很强数学功底,而循环节的方法如果循环节比较大就不太好发现了。这种已知通项公式的题还是用矩阵快速幂比较通用,但同是矩阵快速幂,对于这题,也有很大的差异; 注:memmove这个函数可能不太常见,但还是比较好用的,可以用较低的时间复杂度完成数组的拷贝 方法一 T...

188

【考研高数-高等数学-基础】第一章 函数、极限、连续

第一章 函数、极限、连续 第二章 导数与微分 第三章 微分中值定理及导数应用 第四章 不定积分 第五章 定积分与反常积分 第六章 定积分的应用 第七章 微分方程 第八章 多元函数微分学 第九章 二重积分 第十章 无穷级数 第十一章 向量代数与空间解析几何及多元微分学在几何上的应用 第十二章 多元积分学及其应用 难题: 极限的递推 微分中值定理的证明题 定积分的不等式和等式的证明 重积分的不等式和等式的证明 线面积分的不等式和等...

刘鑫磊 2034

【nnUNetv2进阶】三、nnUNetv2 自定义网络-发paper必会

对于很多朋友来说,找到nnunet的网络结构位置的代码可能比较困难,因为nnunet的网络结构从else:代码中没有网络结构的类名,那么使用的网络是哪个呢?打开预处理后的数据集中的nnUNetPlans.json文件,如下图,configurations里面有2d、3d_fullres等,这些表示nnunet的模型,下面的network_class_name指的就是训练使用的模型结构,一般都是PlainConvUNet。

AI爱好者的博客,分享计算机领域相关知识 8757

hdu 2802 F(N)(递推)

http://acm.hdu.edu.cn/showproblem.php?pid=2802 F(N) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4378    Accepted Submission(s): 1523

大太阳 693

【GameFramework框架】三、快速启动

这篇文章就带领大家如何快速启动GameFramework框架。

优快云博客专家,Unity3D高级软件工程师,《Unity 3D从入门到实战》作者。 4427

HDU 2802 F(N) (找循环节)

转载请注明出处: 题目链接:

1353

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

hdu---2802---F(N)

题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=2802 Problem Description Giving the N, can you tell me the answer of F(N)? Input Each test case contains a single integer N(1<=N&...

weixin_30814319的博客 104

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

hdu 2802 F(N)

Problem Description Giving the N, can you tell me the answer of F(N)?   Input Each test case contains a single integer N(1   Output For each test case, output on a line the

海阔天空 621

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

HDU 2802 F(N)(数论)

Description 已知F(n)-n^3=F(n-2)-(n-1)^3,F(1)=1,F(2)=7,给出n,求F(n)%2009 Input 多组输入,每组用例占一行为一整数n,以n=0结束输入 Output 对于每个n,输出F(n)%2009 Sample Input 1 2 3 0 Sample Output 1 7 20 Solution 显然F(2*k)和

ZSQ 612

数学问题 Hdu 2802 F(n)

F(N) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1651 Accepted Submission(s): 542 Problem Description Giving the N, can you

u012855875的专栏 669

hdu 2802 F(N) 循环解(水)

http://acm.hdu.edu.cn/showproblem.php?pid=2802 /* 2011-9-19 author:BearFly1990 */ package acm.hdu.tests; import java.io.BufferedInputStrea

665

HDU 2802 F(N) [Ad Hoc]

Description给一个公式,求F(N)Algorithm肯定是有循环 不然O(N)都TLE,直接找循环节,然后就变成周期问题了Hint找循环节那个数组范围要开大,其次数据类型也要是long longCode#include <cmath> #include <iostream> using namespace std; const int maxn = 5000; const int kmod

more time 622

HDU 2802 F(N)(寻找循环节)

按照题意打表 1e9 一定超时,所以一定存在规律,将上述公式化简为 f(n)=f(n-2)+3*n*(n-1)+1 后进行打表,找到循环节之后,问题就解决了 const int N=1e5+5; const ll mod=2009; int n,m,t; int i,j,k; int a[N]; ll dp[N],cur; void init() { dp[1]=1; dp[2]=7; for(i=3;i<=100000;i...

C_Dreamy的博客 445

HDU 2802 F(N) 数论+打表

题目大意:f[n]-n^3=f[n-2]-(n-1)^3 (n >=3),f[1]=1,f[2]=7,求f[n]。 题目思路:将n^3移到到等式右边化简的到:f[n]=f[n-2]+3n*(n-1)+1; 因为第n项与第n-2项有关,所以知道了f[1]与f[2]的值可以分奇偶打下表,找到循环节为4018。 #include<cstdio> #include<...

weixin_30654419的博客 95

HDU 2802 F(N)(简单题,找循环解)

题目链接 F(N)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4579 Accepted Submission(s): 1610Problem Description Giving the N, can you tell

王猛旗的博客 510
上一篇: 高斯消元模板(kuangbin大神版本)
New-Spirit
博客等级 码龄14年 13粉丝 138原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值