HDU1028 Ignatius and the Princess III

超大规模系统(千万级用户)中实现字段级权限控制 摘要:本文提出了一套分布式架构下的字段级权限优化方案,结合RBAC+ABAC混合模型与技术手段实现性能与安全的平衡。方案包括:1)权限模型优化,采用RBAC预计算基础权限与ABAC动态校验敏感字段;2)数据层优化,实现动态字段过滤与加密存储;3)多级缓存策略与预计算机制提升性能;4)分布式架构设计,通过网关校验和策略引擎集群保证扩展性。最终在千万级用户系统中实现99.9%可用性,权限校验延迟控制在50ms以内。 阅读详情

Ignatius and the Princess III
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 29 Accepted Submission(s) : 7
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
“Well, it seems the first problem is too easy. I will let you know how foolish you are later.” feng5166 says.

“The second problem is, given an positive integer N, we define an equation like this:
N=a[1]+a[2]+a[3]+…+a[m];
a[i]>0,1<=m<=N;
My question is how many different equations you can find for a given N.
For example, assume N is 4, we can find:
4 = 4;
4 = 3 + 1;
4 = 2 + 2;
4 = 2 + 1 + 1;
4 = 1 + 1 + 1 + 1;
so the result is 5 when N is 4. Note that “4 = 3 + 1” and “4 = 1 + 3” is the same in this problem. Now, you do it!”
Input
The input contains several test cases. Each test case contains a positive integer N(1<=N<=120) which is mentioned above. The input is terminated by the end of file.
Output
For each test case, you have to output a line contains an integer P which indicate the different equations you have found.
Sample Input
4
10
20
Sample Output
5
42
627

做这题的时候我就想到了这题和放苹果有点像,
(放苹果)
只是变成了n个盘子n个苹果,所以我继续使用这个函数。

放苹果的函数代码

int fun(int m,int n)
{
    if(m==0||n==1)
        return 1;
    if(m <n)
        return fun(m,m);
    else
        return fun(m,n-1)+fun(m-n,n);
}

但是当这样写出来后发现如果是输入120的话就超时了,计算量太大了。
于是改进一下,先算出来,用一个二维数组存起来。

代码

#include <bits/stdc++.h>
using namespace std;
int a[125][125];
void fun()
{
    for(int i=1; i<125; i++)
        for(int j=1; j<125; j++)
        {
            if(i==1||j==1)
                a[i][j]=1;
            else if(i <j)
                a[i][j]=a[i][i];
            else if(i==j)
                a[i][j]=a[i][j-1]+1;
            else
                a[i][j]=a[i][j-1]+a[i-j][j];
        }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m;
    fun();
    while(cin>>m)
    {
        cout<<a[m][m]<<endl;
    }
    return 0;
}

然后这样的话就不用每输入一个数都要重新算一遍,也就节省了时间。

廖雪峰Python教程[完整版] 廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白 立即下载

相关推荐

OpenSpec 从入门到精通:AI 时代的最佳 SDD 范式

同样都是「先写规范再写代码」的开源 SDD 框架,OpenSpec(https://github.com/fission-ai/openspec) 展现出了极高的工程性价比,无论是使用 Claude Code、Cursor 还是 Aider,都可以无缝接入 OpenSpec 的规格管理层。这些问题需要人来做判断,AI 做不了这个主。整个流程跑下来,OpenSpec 产出的效果还是令人满意的,一些前期没有考虑到的细节 AI 都补上了,生成的相关文档也有利于开发人员的知识对齐,可以尝试在团队内部推广。

qq_39093474的博客 962

HDU——1028 Ignatius and the Princess III(母函数)

Problem Description “Well, it seems the first problem is too easy. I will let you know how foolish you are later.” feng5166 says. “The second problem is, given an positive integer N, we define an eq...

LightOn 255

5G R18标准:AI/ML如何重塑空口优化与网络架构

人工智能与机器学习正逐步成为通信网络优化的核心技术。其核心原理在于通过数据驱动模型,从海量网络数据中学习信道变化、用户行为等统计规律,替代传统的基于固定规则的优化方法。这一技术范式能显著提升网络性能与效率,尤其在空口资源管理、干扰协调和能耗控制等场景中价值突出。在5G Advanced(R18)标准化框架下,AI/ML被系统性地引入空口设计,聚焦于信道状态信息反馈增强、波束管理与预测等关键用例。通过定义网络侧AI、终端侧AI及联合学习的标准化接口与流程,R18旨在实现跨厂商设备的智能协同,推动无线网络向自适

weixin_35671843的博客 252

HDU1028——Ignatius and the Princess III(背包问题dp)

Ignatius and the Princess III 活水源头 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 18990    Accepted Submission(s): 13348 Problem Des

curson_的博客 446

stm32f407VET6 系统学习 day01 GPIO 配置

stm32f407VET6 系统学习 day01 GPIO 配置 LED 蜂鸣器 按键的不讲了,之前讲过了

she666666的博客 8914

3D医学影像分割新突破:手把手教你用MedSAM2快速标注CT/MRI数据(附3D Slicer插件配置)

本文详细介绍了如何利用MedSAM2模型进行3D医学影像分割,包括从环境准备到3D Slicer插件配置的全流程。通过实战案例和技巧分享,帮助医疗从业者快速掌握CT/MRI数据的高效标注方法,提升医学影像分析的准确性和效率。

ujm5678901的博客 307

hdu1028 Ignatius and the Princess III (完全背包)

Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 16474    Accepted Submission(s): 11609 Problem Descr

把复杂的事情简单描述 796

ABAP BOM展开避坑指南:CS_BOM_EXPL_MAT_V2函数参数配置详解

本文深入解析了SAP ABAP开发中用于物料清单展开的核心函数CS_BOM_EXPL_MAT_V2。针对其复杂的参数配置,如CAPID、STLAN、DATUV和MEHRS,提供了详细的避坑指南和最佳实践,帮助开发者避免数据错误与性能陷阱,实现高效、准确的BOM多层展开。

pea55的博客 869

HDU - 1028——母函数入门

【题目描述】 “Well, it seems the first problem is too easy. I will let you know how foolish you are later.” feng5166 says. “The second problem is, given an positive integer N, we define an equation like thi...

T_T233333333的博客 577

YOLOv11改进策略【注意力机制篇】| SE、CBAM、ECA、CA、Swin Transformer等注意力机制全面解析与应用

本文详细介绍了五种主流的注意力机制及其在YOLOv11中的应用。通过合理的模块选择和位置部署,注意力机制能够显著提升目标检测性能。

QQ_778132974的博客 880

华为OD机试双机位C卷-部门人力分配 (Py/Java/C/C++/Js/Go)

华为OD机试(机考)双机位C卷 【部门人力分配】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试 - 部门人力分配。

qq_45776114的博客 1880

杭电 OJ 1028 整数划分

Problem Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says. "The second problem is, given an positive integer N, we define a

ssdut_209的博客 3631

实战|基于Kappa架构的用户行为实时分析平台搭建教程

数据源:用Kafka存储全量数据(实时+历史),作为“事实来源”;处理引擎:用Flink等流处理引擎,读取Kafka中的数据,执行清洗、转换、聚合等操作;存储层:将处理结果写入实时存储(如Elasticsearch)或批量存储(如Hive);消费层:用可视化工具(如Kibana)展示结果,或提供API供业务系统调用。Kappa架构的关键设计原则全量数据存于Kafka:Kafka的“无限 retention”特性(默认保留7天,可配置更长)让它成为全量数据的存储介质;用流处理引擎处理所有数据。

Java大师兄的博客 800

HDU1028 Ignatius and the Princess III 生成函数

HDU1028 Ignatius and the Princess III 题意: 给一个整数n,将其拆成整数的和,问有多少种拆分方法。 解题思路: 每次将两个()里面的合并为一个,并只保存指数小于等于 n 的项 。 AC代码: #include&lt;iostream&gt; #include&lt;cstdio&gt; using namespace st...

Hagtaril 302

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

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

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

HDU 1028 Ignatius and the Princess III(母函数)

题目:HDU-1028  题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 题目: Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su

桐小目的秘密基地 575

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

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

HDU 1028: Ignatius and the Princess III

HDU 1028: Ignatius and the Princess III ///@author Sycamore, ZJNU ///@date 7/28/2017 #include<bits/stdc++.h> using namespace std; const int MAXN=125; int main() { int n; while...

weixin_30783629的博客 94

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

HDU 1028 Ignatius and the Princess III

HDU 1028 Ignatius and the Princess III 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1028 题意:将一个整数拆成若干整数和 求分解的方案有几种 其中 7=5+1+1与7=1+5+1视为一种 常规思路是用母函数写 算是母函数入门题 母函数原型:(x ^ 0 + x ^ 1 + x ^ 2 + … + x^n) *...

尘寒的博客 228

hdu 1028 Ignatius and the Princess III 简单dp

题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是dp[i][i]。那么dp[i][j]=dp[i][j-1]+dp[i-j][i-j],dp[i][j-1]是累加1到j-1的结果,dp[i-j][i-j]表示的就是最大为j,然后i-j有多少种...

weixin_30407099的博客 98

Hdu 1028 Ignatius and the Princess III//整数划分(一)

直接代码吧: /*Hdu 1028 Ignatius and the Princess III 整数划分 */ #include #include using namespace std; const int maxn = 150; int f[maxn][maxn]; int n; int main() { while(cin>>n) { for

mr_zys的专栏 709

ACM: HDU 1028 Ignatius and the Princess III-DP

HDU 1028Ignatius and the Princess III Time Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64u Description "Well, it seems the first problem is too easy. I will ...

weixin_30455661的博客 162

hdu 1028 Ignatius and the Princess III

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 思路一:和hdu1398 1284一样 思路二:参考自http://www.cnblogs.com/xingluzhe/archive/2009/09/01/1557844.html code1 #include #include #include #include using

u010304217的专栏 2189

hdu1028 Ignatius and the Princess III

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1028 递归能跑。。。 但是我交了直接超时了,然后我就把数据跑出来了再交的,等的时间有点长(怪不得超时)。 过的有点猥琐,看别人代码用母函数过的。 1 #include 2 #includestring.h> 3 #include 4 #include 5 #include

xuesen1995的专栏 150

HDU:1028 Ignatius and the Princess III

母函数

温姑娘的博客 273

hdu1028 Ignatius and the Princess III 母函数模板题

/*     hdu1028 Ignatius and the Princess III     母函数的模板题 关键在于构建好母函数就行, 练练手吧 */ #include #include #include using namespace std; #define MAXN 122 int c1[MAXN],c2[MAXN],n; int main() { in

224
上一篇: 放苹果(递归解法)
下一篇: HDU 2062 Subset sequence
jovie Hung
博客等级 码龄7年 19粉丝 22原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值