Ant Counting(DP)

SM2258XT开卡量产实战:短接ROM、Flash识别与参数配置全流程 SSD掉盘、容量异常或显示SATAFIRM S11,通常指向固件层与FTL映射表异常,而非颗粒物理损坏。其底层原理是主控通过ROM引导重新初始化,重建坏块表、逻辑到物理地址映射、SMART与容量参数,使盘恢复可用状态。从技术价值看,SSD开卡与固态硬盘量产能降低白牌盘、工控盘和移动硬盘盒的报废率,也能验证颗粒真实健康度。常见应用场景包括SATA SSD掉盘修复、廉价固态复活、二手颗粒筛选与容量档位重设。围绕慧荣SM2258XT无DRAM主控,需匹配量产工具与固件,处理短接进ROM、Flash ID识别、OP 阅读详情

Description
Bessie was poking around the ant hill one day watching the ants march to and fro while gathering food. She realized that many of the ants were siblings, indistinguishable from one another. She also realized the sometimes only one ant would go for food, sometimes a few, and sometimes all of them. This made for a large number of different sets of ants!

Being a bit mathematical, Bessie started wondering. Bessie noted that the hive has T (1 <= T <= 1,000) families of ants which she labeled 1..T (A ants altogether). Each family had some number Ni (1 <= Ni <= 100) of ants.

How many groups of sizes S, S+1, …, B (1 <= S <= B <= A) can be formed?

While observing one group, the set of three ant families was seen as {1, 1, 2, 2, 3}, though rarely in that order. The possible sets of marching ants were:

3 sets with 1 ant: {1} {2} {3}
5 sets with 2 ants: {1,1} {1,2} {1,3} {2,2} {2,3}
5 sets with 3 ants: {1,1,2} {1,1,3} {1,2,2} {1,2,3} {2,2,3}
3 sets with 4 ants: {1,2,2,3} {1,1,2,2} {1,1,2,3}
1 set with 5 ants: {1,1,2,2,3}

Your job is to count the number of possible sets of ants given the data above.
Input
* Line 1: 4 space-separated integers: T, A, S, and B

  • Lines 2..A+1: Each line contains a single integer that is an ant type present in the hive
    Output
  • Line 1: The number of sets of size S..B (inclusive) that can be created. A set like {1,2} is the same as the set {2,1} and should not be double-counted. Print only the LAST SIX DIGITS of this number, with no leading zeroes or spaces.
    Sample Input
    3 5 2 3
    1
    2
    2
    1
    3
    Sample Output
    10
    Hint
    INPUT DETAILS:

Three types of ants (1..3); 5 ants altogether. How many sets of size 2 or size 3 can be made?

OUTPUT DETAILS:

5 sets of ants with two members; 5 more sets of ants with three members

有n个蚂蚁家族,每个家族至少一个蚂蚁,并且相互之前无区别,问取出i个蚂蚁有多少种取法(s <= i <= b)

最暴力的办法O(TA^2)
dp[i][j]来讲,可以由dp[i - 1][j - k] (0 <=k<= min(num[i],j)转移而来,然后没有超时……

#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<utility>
#include<sstream>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
int num[1005],dp[100005];
int main()
{
    #ifdef LOCAL
    freopen("C:\\Users\\ΡΡ\\Desktop\\in.txt","r",stdin);
    //freopen("C:\\Users\\ΡΡ\\Desktop\\out.txt","w",stdout);
    #endif // LOCAL
    int t,a,s,b;
    scanf("%d%d%d%d",&t,&a,&s,&b);
    memset(num,0,sizeof(num));
    for(int i = 1;i <= a;i++)
    {
        int x;
        scanf("%d",&x);
        num[x]++;
    }
    memset(dp,0,sizeof(dp));
    dp[0] = 1;
    for(int i = 1;i <= t;i++)
    {
        for(int j = b;j >= 0;j--)
        {
            for(int k = 1;k <= min(num[i],j);k++)
                dp[j] = (dp[j] + dp[j - k])%1000000;
        }
    }
    int ans = 0;
    for(int i = s;i <= b;i++)
        ans = (ans + dp[i])%1000000;
    printf("%d\n",ans);
    return 0;
}

下面讲一下O(TA)的正解- -
刚才那个式子由挑战69页可推导
即是
dp[i][j] = dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1 - num[i]];
dp[i][j] = dp[i][j - 1] + dp[i - 1][j]);
这是一个恒等式,可以证明,实际含义就是前面的连续段可以用dp[i][j - 1]来表示,对于重合的部分还需要减去,取得的最小值不同,减去的数也不同。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<utility>
#include<sstream>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
const int mod = 1000000;
int num[1005],dp[2][100005];
int main()
{
    #ifdef LOCAL
    freopen("C:\\Users\\ΡΡ\\Desktop\\in.txt","r",stdin);
    //freopen("C:\\Users\\ΡΡ\\Desktop\\out.txt","w",stdout);
    #endif // LOCAL
    int t,a,s,b;
    scanf("%d%d%d%d",&t,&a,&s,&b);
    for(int i = 1;i <= a;i++)
    {
        int x;
        scanf("%d",&x);
        num[x]++;
    }
    memset(dp,0,sizeof(dp));
    dp[0][0] = dp[1][0] = 1;
    for(int i = 1;i <= t;i++)
    {
        for(int j = 1;j <= b;j++)
        {
            if(j - 1 - num[i] >= 0)
                dp[i&1][j] = (dp[i&1][j - 1] + dp[(i - 1)&1][j] - dp[(i - 1)&1][j - 1 - num[i]] + mod)%mod;
            else
                dp[i&1][j] = (dp[i&1][j - 1] + dp[(i - 1)&1][j])%mod;
        }
    }
    int ans = 0;
    for(int i = s;i <= b;i++)
        ans = (ans + dp[t&1][i])%mod;
    printf("%d\n",ans);
    return 0;
}
RT-DETR训练自己的数据集(从代码下载到实例测试) 在Windows10上配置CUDA环境教程是百度提出的一种实时目标检测模型。RT-DETR采用了与DETR相同的编码器和解码器结构,但对其进行了大量的优化,在保持较高检测精度的同时,实现了实时目标检测,为目标检测领域提供了一种新的有效解决方案,具有广泛的应用前景,如自动驾驶、智能监控、机器人等领域。以上是RT-DETR官方的论文和代码,详细介绍了RT-DETR的构成和实现。在YOLOv10中也实现了RT-DETR的代码,所以本文使用YOLOv10的项目文件进行RT-DETR的训练和测试。YOLOv10。 阅读详情

相关推荐

本地部署Llama 3中文版:Ollama量化配置与调优指南

大模型本地部署正在成为数据敏感场景下的主流选择。本地运行开源大模型,既能保护隐私又能降低调用成本,但中文能力往往成为瓶颈。以Llama 3为代表的开源模型,需借助中文微调与量化技术,才能在消费级显卡上流畅运行。量化通过压缩模型权重减小显存占用,配合Ollama等推理框架,可快速搭建私有中文AI服务。该方案适用于知识库问答、内容生成、离线助手等场景,并可通过OpenAI兼容接口无缝对接Dify等应用平台。本文从硬件选型、量化等级到Modelfile配置,系统梳理本地部署中文大模型的全链路实战方法与排错思路,帮

weixin_29035405的博客 82

动态规划——Ant Counting(多重级组合数)

Ant Counting POJ - 3046(中文翻译) 有一天,贝茜无聊地坐在蚂蚁洞前看蚂蚁们进进出出地搬运食物.很快贝茜发现有些蚂蚁长得几乎一模一样,于是她认为那些蚂蚁是兄弟,也就是说它们是同一个家族里的成员.她也发现整个蚂蚁群里有时只有一只出来觅食,有时是几只,有时干脆整个蚁群一起出来.这样一来,蚂蚁们出行觅食时的组队方案就有很多种.作为一头有数学头脑的奶牛,贝茜注意到整个蚂蚁群由T(1...

weixin_43519121的博客 515

Dify社区版多工作空间功能解锁:源码修改与多租户架构解析

多租户架构是现代SaaS平台实现数据隔离与资源管理的核心技术,其核心原理是通过租户模型将用户、应用和数据在逻辑上隔离。在AI应用开发平台中,这种架构能有效支持多团队、多项目并行开发,确保不同业务线的数据安全与独立迭代。Dify作为开源AI应用构建平台,其底层已设计完善的多租户模型,但社区版默认限制了单用户单工作空间。本文通过精准修改两处关键代码——账户初始化逻辑与系统功能开关,释放了平台固有的多工作空间管理能力。该方案无需改动数据库结构,直接利用现有RBAC权限体系,实现了类似企业版的**多租户隔离**体验

weixin_27059669的博客 1055

POJ3046 Ant Counting 题解

博客园同步 原题链接 朴素动态规划。 用 fi,jf_{i,j}fi,j​ 表示前 iii 种 蚂蚁选了 jjj 种 的方案数。类似背包。 首先不考虑个数限制, fi,j=fi−1,j+fi,j−1f_{i,j} = f_{i-1,j} + f_{i,j-1}fi,j​=fi−1,j​+fi,j−1​. 这样完成了多重背包的效果(就是 fif_ifi​ 的那一行在不断滚动),但是若设第 iii 种蚂蚁有 aia_iai​ 个,则不能完全背包。考虑如何解决限制。 把超过的那部分减去:很明显,这样的背包很可能第

bifanwen的博客 253

模电专题-MOS管的放大电路分析

在实际应用中,我们经常会使用到功率MOS,这时通常不会将它当成一个开关使用,而是当成一个放大器来使用,那这就需要让其工作在放大状态。参考下图中的mos管的特性曲线,右图中的输出特性曲线中有一根红色的分界线,这个线就是区分mos管工作状态的分界线,在红线的左边,mos管工作在可变电阻区,也就是线性区;在红线的右边mos管工作在恒流区,也就是饱和区。当然,还有一个截止区。本文分析主要运用模电课本中的理论计算验证。

Anitawen的博客 2万+

海康线扫相机平场矫正实战:从原理到精准成像

本文深入解析了海康线扫相机平场矫正的原理与实战操作。通过拆解暗场与明场矫正的物理意义,揭示了其消除系统噪声、补偿像素响应不均的核心机制。文章详细指导了在海康相机上进行平场矫正的标准化流程、关键参数设置(如行高、灰度值控制)及常见误区,并提供了针对高行频匹配、环境稳定性维护等进阶调优技巧与问题排查指南,旨在帮助用户实现从原理理解到精准成像的跨越。

tomato的博客 789

Ant Counting(多重背包计数 + 优化)

Ant Counting 题目 t种蚂蚁,总共n只,从中挑出i只,求从中挑出l只到r只的所有挑法。 思路 显然是dp , 定义dp为从前i只挑出j只的方案集合,记录它的数量count。 状态转移是从 dp[i-1][j-k] ==> dp[i][j] 也即 : dp[i][j] = SUM(dp[i-1][j-k]) (0<=k<=min(该种蚂蚁最大个数,j) 这是一个O(nmm)的算法(虽然这题数据挺水,也可以过) 对于10^5数据量 ,需要优化到O(nm) 。 回到dp

weixin_58110654的博客 472

基于simulink的变压器保护仿真设计【MATLAB源码+Word文档】

电力系统变压器保护MATLAB/simulink仿真设计。纵联差动保护-过电流保护-距离保护

weixin_761237174的博客 1270

G - Ant Counting--(DP)

SOS!!! 题意:蚂蚁们来自3个家庭,每个家庭内部成员一个样,不同家庭不一样。从里面选s个,能有几种组合,选b个有几种组合。s的组合数加上b的组合数。 我看的题解是分组背包(有些疑问) 先上代码 #include &amp;amp;amp;amp;lt;iostream&amp;amp;amp;amp;gt; #include &amp;amp;amp;amp;lt;cstdio&amp;amp;amp;amp;gt; #include &amp;amp

超级菜 537

QGis软件 —— 9、QGis - 由点绘制热力图来模拟人流量(绘制点方式、excel导入数据方式)

QGis软件 —— 9、QGis - 由点绘制热力图来模拟人流量(绘制点方式、excel导入数据方式)

1469

【GlobalMapper精品教程】038:模拟水位上升(洪水淹没分析)案例教程

基于数字高程模型 ( DEM )格网模型,实现给定水深情况下洪水淹没区的计算模型,讨论洪水淹没演进过程可视化实现的关键技术,以三维可视化方式,动态而形象地模拟在指定洪水水位下的洪水淹没演进过程。

智慧空间实验室 2882

北大ACM——3046,Ant Counting(DP)

题意:有T种蚂蚁,总共A只,求将这些蚂蚁,分为数量为S,S+1,S+2,…,B的集合的总集合数。 突破口: 设置a[T]记录每种蚂蚁的数量,设置dp[i,j]表示,用前i种蚂蚁,构成数量为j的集合的最大集合数,那么,第i种蚂蚁有用0只,1只,…,a[T]只,因此,状态转移方程应为: dp[i,j]=sum(dp[i-1,j~j-a[T]]). 代码如下: #include<cstdio&gt...

shamansi99的博客 290

PMP--二模--解题--161-170

A:邀请团队成员在下一次回顾中分享经验。B:请求发起人增加具有所需经验的团队成员。C:在团队内计划知识共享会议。D:请求发起人为团队提供培训课程。A。

stqer的博客 1268

POJ 3046 Ant Counting 简单DP

题意也比较简单了。  大概是: 给出T种数字。每种各有N[i]个 然后用这些数字构成一些序列, 问x长度到y长度的序列有多少种 那么就是DP了 dp[i][j] 表示前i种数字构成长度为j的序列有多少种 然后 dp[i][j] = sigma(dp[i - 1][j - k]) k的范围是0~N[i] 注意到这里的sigma(dp[i - 1][j - k]) 可以用部分和

水 4063

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Ant Counting POJ 3046(计数dp)

原题 题目链接 题目分析 计数dp题,感觉其实也可以用组合数学做,但我太菜了,推不出通用公式.dp可以定义dp[i][j]为前i种选j个蚂蚁有多少种选法,然后递推公式如下,其中c[i]表示第i种的数量, dp[i][j]=Σ(min(j,c[i]),k=0)dp[i-1][j-k].可以化简一下,dp[i][j]=∑(c[i],k=0)dp[i-1][j-1-k]+dp[i-1]...

dashengchong6303的博客 166

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

[POJ 3046]Ant Counting[dp][优化]

题目链接:[POJ 3046]Ant Counting[dp][优化] 题意分析: 蚂蚁有T个家族,每个家族里的蚂蚁没有区别,总共有A只蚂蚁,现在问:给出每个家族的蚂蚁数量,最多能组合成多少个不同的集合个数为S~B的集合? 就是给你T个集合,每个集合num[i]num[i]个数,这些数排列组合能有多少个,个数为S~B的集合。 解题思路: 本题不能有重复情况,即{1,2}{2,1}是相同的,

闲停 710

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

POJ Ant Counting DP

dp[i][j]表示前i种蚂蚁组成元素个数为j的集合有多少种。 则dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + ... + dp[i-1][ max(0,j-a[i])]; 直接算的话复杂度为O(TA^2) 状态的转移是一个区间内的数的和,所以再用一个数组f[i][j]记录dp[i][j]的前缀和。 dp[i][j] = f[i-1][j]-f[i-1][j...

weixin_33916256的博客 62

POJ 3046 Ant Counting dp

定义状态为前i种蚂蚁能够形成大小为j的集合的种数 注意到每次都要求一段dp数字的和,我们可以使用一个前缀数组sum。 由于sum数组的使用,我们可以在O(1)的时间内算出dp(i, j) 同时注意到dp(i, j)只和dp(i - 1, j)有关系,所以我们可以用滚动数组来实现。 最后复杂度为O(T * A) #include #include #include #

每天都要进步哦~ 428

poj3046 Ant Counting(dp)

与昨天一道类似的多重集组合数问题 每个家族有n个蚂蚁,一共T个家族, 问从S到B能有多少组合可能 题目: G - Ant Counting Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Appoint descr...

aiezhen1717的博客 224

POJ 3046 Ant Counting DP题目

题目大意:有T个种类的蚂蚁family,下面给你a只蚂蚁,数字代表来自第几个family的,求在这a只中取出x只组成长度大小在[s,b]之间的集合数量有多少个。转化一下题意,给你T种类型 a 个个体,从中任取 [s,b] 个组成的集合个数有多少个。这道题用 DP 的思想解答。令 dp[i][j] 表示前i个种类中组合成大小为j的集合的个数。所以可以枚举 1~T 种之间,每一种 a[i-1](这里i...

chen_YongZu的博客 410

poj 3046 Ant Counting dp 优化

《挑战》练习题,dp+优化。

ned_chu的博客 442

poj-3046 Ant Counting【dp】【母函数】

题目链接:戳这里 题意:有A只蚂蚁,来自T个家族,每个家族有ti只蚂蚁。任取n只蚂蚁(S <= n <= B),求能组成几种集合? 这道题可以用dp或母函数求。 多重集组合数也是由多重背包问题拓展出来的一类经典问题,而此类问题也都可以用母函数求. 给大家讲2种方法: ①朴素方法: 状态:dp[i][j]:前i种中选j个可以组成的集合数 决策:第i种选k个,k&...

weixin_30566149的博客 177

dp: POJ 3046 Ant Counting

Description Bessie was poking around the ant hill one day watching the ants march to and fro while gathering food. She realized that many of the ants were siblings, indistinguishable from one another.

Davenny:~我今天该吃点什么捏~ 415

DP:Ant Counting(POJ 3046)

                                      数蚂蚁   题目大意:一只牛想数蚂蚁,蚂蚁分成很多组,每个组里面有很多只蚂蚁,现在问你有多少种组合方式        (说白了就是问1,1,1,...,2...,3...,4...)这些东西有多少种排列组合方式   这一道题我一开始想着去用矩阵乘法去做了,结果怎么想怎么不对,后来想着,如果对1,2...

bandilan2400的博客 88

poj 3046 Ant Counting (dp)

Ant Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5066   Accepted: 1920 Description Bessie was poking around the ant hill one day watching the ant

clover_hxy的博客 349

Ant Counting POJ - 3046 (DP)

Ant Counting POJ - 3046 (DP) 题目链接 题目大意:t种蚂蚁,一共n个,问把他们分组,分成每个集合里面有k个,s&lt;=k&lt;= e,问多少种分法。 While observing one group, the set of three ant families was seen as {1, 1, 2, 2, 3}, though rarely in ...

deerly_的博客 233
上一篇: Coins(背包DP)
下一篇: Dollar Dayz(DP)
Techay
博客等级 码龄11年 11粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值