【搜索】WAR大佬的SET @upcexam6201

【模拟】[NOIP2014]螺旋矩阵[c++] 题目描述 一个n行n列的螺旋矩阵可由如下方法生成: 从矩阵的左上角(第1行第1列)出发,初始时向右移动;如果前方是未曾经过的格子,则继续前进,否则右转;重复上述操作直至经过矩阵中所有格子。根据经过顺序,在格子中依次填入1, 2, 3, … , n,便构成了一个螺旋矩阵。 阅读详情

时间限制: 1 Sec 内存限制: 128 MB
题目描述
WAR大佬认为一个包含重复元素的集合认为是优美的,当且仅当集合中的元素的和等于他们的积。
求包含n个元素的优美的集合的个数。
WAR大佬当然会啊,他只是想考考你。
输入
一个正整数n(2<=n<=1000)
输出
一个数ans表示集合的个数
样例输入
5
样例输出
3
提示
1+1+1+2+5=1*1*1*2*5
1+1+1+3+3=1*1*1*3*3
1+1+2+2+2=1*1*2*2*2

dfs,注意题目说了必须要有重复元素
剪枝条件是后面每位都用当前数且exmul*幂大于exsum+和时

#define FILE() freopen("../../in.txt","r",stdin)
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1005;

ll fstpow(ll a,ll n) {
    ll res = 1;
    while(n) {
        if(n&1)res*=a;
        a*=a;
        n>>=1;
    }
    return res;
}

ll dfs(ll _digit,ll _num,ll _exmul,ll _exsum) {
    _exmul*=_num;
    _exsum+=_num;
    if(_digit==1) {
        if(_exmul==_exsum)return 1;
        else return 0;
    }
    ll ans = 0;
    for(ll i=_num;; i++) {
        if(_exmul*fstpow(i,_digit-1)>_exsum+i*(_digit-1))break;
        if(_digit==2&&_num==1)break;
        ans+=dfs(_digit-1,i,_exmul,_exsum);
    }
    return ans;
}

int main() {
//    FILE();
//    freopen("../../out.txt","w",stdout);
    ll n;
    scanf("%lld",&n);
    if(n==2||n==3)printf("0\n");
    else {
        ll ans = 0;
        ll digit = min(n,32ll);
        ans=dfs(digit,1,1,n-digit);
        printf("%lld\n",ans);
    }
    return 0;
}
【枚举】珠心算测验[c++] 题目描述 珠心算是一种通过在脑中模拟算盘变化来完成快速运算的一种计算技术。珠心算训练,既能够开发智力,又能够为日常生活带来很多便利,因而在很多学校得到普及。 某学校的珠心算老师采用一种快速考察珠心算加法能力的测验方法。他随机生成一个正整数集合,集合中的数各不相同,然后要求学生回答:其中有多少个数,恰好等于集合中另外两个(不同的)数之和? 最近老师出了一些测验题,请你帮忙求出答案。 阅读详情

相关推荐

【模拟】[NOIP2011]铺地毯[c++]

题目描述 为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯,一共有n张地毯,编号从 1 到n。现在将这些地毯按照编号从小到大的顺序平行于坐标轴先后铺设,后铺的地毯覆盖在前面已经铺好的地毯之上。 地毯铺设完成后,组织者想知道覆盖地面某个点的最上面的那张地毯的编号。注意:在矩形地毯边界和四个顶点上的点也算被地毯覆盖。

银狼的黎明 2081

WAR大佬的SET

6201: WAR大佬的SET时间限制: 1 Sec  内存限制: 128 MB提交: 59  解决: 16[提交][状态][讨论版][命题人:admin]题目描述WAR大佬认为一个包含重复元素的集合认为是优美的,当且仅当集合中的元素的和等于他们的积。求包含n个元素的优美的集合的个数。WAR大佬当然会啊,他只是想考考你。输入一个正整数n(2&lt;=n&lt;=1000)输出一个数ans表示集合的...

Sinhaeng_Hhjian 371

【LCA&倍增】货物运输 @upcexam5909

时间限制: 1 Sec 内存限制: 128 MB 题目描述 在一片苍茫的大海上,有n座岛屿,岛屿与岛屿之间由桥梁连接,所有的岛屿刚好被桥梁连接成一个树形结构,即共n-1架桥梁,且从任何一座岛屿出发都能到达其他任何一座岛屿。 第i座桥梁有一个承重量wi,表示该桥梁一次性最多通过重量为wi的货物。 现在有m个货物运输路线,第i个路线要从岛屿xi出发到达岛屿yi。为了最大化利益,你需要求出在不...

银狼的黎明 286

Linux下使用gcc生成动态库.so和调用(图文并茂,坑已踩完)

简 述: 继 上一篇。本篇就继续实践踩坑,实现在Linux上面,使用gcc编译动态库.so,文件,且调用动态库。此处例子实际:使用g++8.3.0在uos20(Linux)平台下完成这个知识点的实践教程。 文章目录编程环境:动态库概念:前期铺垫:将.cpp文件生成.o文件:将.o文件大包为.so文件:调用.so文件:设置.so的运行时的PATH:解决 Linux 加载动态库 .so 文件失败的...

1万+

国央企创新负责人如何通过平台实现科研成果的快速识别与转化?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

保姆级教程:用PyBullet和Stable-Baselines3搞定你的第一个机器人强化学习项目

本文提供了一份详细的PyBullet和Stable-Baselines3教程,帮助开发者快速上手机器人强化学习项目。通过环境配置、自定义Gym环境构建、PPO算法参数优化及模型部署的全流程解析,读者将掌握从零开始训练四足机器人 locomotion 任务的完整技术方案。

weixin_26861329的博客 420

【倍增】T-shirt @2018acm徐州邀请赛 I

问题 I: T-shirt时间限制: 1 Sec  内存限制: 64 MB题目描述JSZKC is going to spend his vacation! His vacation has N days. Each day, he can choose a T-shirt to wear. Obviously, he doesn’t want to wear a singer color T-s...

银狼的黎明 1166

科研党必备:5分钟搞定Arxiv论文批量导入NoteExpress(附PDF自动下载技巧)

本文为科研人员提供了一套高效的自动化工作流,实现从Arxiv批量检索论文、自动下载PDF到无缝导入NoteExpress的全过程。通过Python脚本和NASA ADS等工具,可大幅提升文献管理效率,特别适合需要追踪前沿动态的研究生和科研团队。

orange的博客 398

【贪心】[hdu1052]Tian Ji -- The Horse Racing(田忌赛马)[c++]

Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

银狼的黎明 837

Manus通用AI智能体完全使用指南(2025最新版)——从注册到高阶技巧全解析

Manus通用AI智能体完全使用指南(2025最新版)——从注册到高阶技巧全解析

m0_69718028的博客 8116

Oracle入门——基础语法篇

ROWID是Oracle中的一个伪列,用于唯一标识数据库中的每一行。在查询中,可以使用ROWID来定位和操作特定的行,例如,删除特定的行或更新特定的行。在Oracle中,子查询是指嵌套在另一个查询内部的查询语句,它可以作为主查询的一部分,用于提供额外的过滤条件、计算或数据源。在Oracle中,连接查询是通过使用JOIN子句将两个或多个表中的数据合并在一起,以获取满足特定条件的结果集。在Oracle数据库中,ROWID和ROWNUM都是用于对行进行标识和定位的伪列,它们在查询中的使用有一些不同之处。

麦当当的博客 3089

【暴力枚举&BFS】Flow Free @RMRC2017/upcexam5124

时间限制: 1 Sec 内存限制: 128 MB 题目描述 Flow Free is a puzzle that is played on a 2D grid of cells, with some cells marked as endpoints of certain colors and the rest of cells being blank. To solve the p

银狼的黎明 716

别再傻傻分不清PBR和NPR了!从《原神》到《双城之战》,聊聊游戏里那些让你眼前一亮的渲染风格

本文深入解析了PBR(基于物理的渲染)与NPR(非真实感渲染)在游戏视觉风格中的应用差异,通过《原神》和《双城之战》的案例,展示了两种渲染技术如何创造出截然不同的艺术效果。从技术原理到实战案例,帮助读者理解如何根据项目需求选择合适的渲染风格。

weixin_30425949的博客 146

【分治-前缀积后缀积】JS Window @2018acm徐州邀请赛G

问题 G: JS Window时间限制: 2 Sec  内存限制: 512 MB题目描述JSZKC has an array A of N integers. More over, he has a Window of length M which means the Window can contain M continuous integers in the array. At the beg...

银狼的黎明 652

【深度学习新浪潮】什么是system 1和system 2?

System 1(快速生成)指大模型直接基于输入生成响应,无需显式中间推理步骤。例如,GPT-4等模型在默认状态下通过Transformer直接输出结果,擅长快速回答简单问题或生成连贯文本,但在复杂逻辑任务中可能出错。这类模型的内部计算以向量形式隐式进行,难以处理符号推理等需要离散决策的任务。System 2(慢速推理)指模型通过生成中间token(如思维链、分步推导)或多次调用LLM进行复杂推理。

专注:太空算力、AI infra、异构调度、大模型成本工程 928

Debezium系列之:使用指定值替代指定字段的值

Debezium系列之:使用指定值替代指定字段的值

zhengzaifeidelushang的博客 306

【倍增】Tak and Hotels II @ABC044&ARC060/upcexam6463

6463: Tak and Hotels II时间限制: 1 Sec  内存限制: 128 MB提交: 40  解决: 11[提交][状态][讨论版][命题人:admin]题目描述N hotels are located on a straight line. The coordinate of the i-th hotel (1≤i≤N) is xi.Tak the traveler has t...

银狼的黎明 563

IEM模型,地表粗糙度模拟

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

【枚举】Consonant Fencity @upcexam5110

时间限制: 3 Sec 内存限制: 512 MB 题目描述 There are two kinds of sounds in spoken languages: vowels and consonants. Vowel is a sound, produced with an open vocal tract; and consonant is pronounced in su...

银狼的黎明 449

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

【二分】Base Station Sites @ICPC2017HongKong/upcexam5559

时间限制: 1 Sec 内存限制: 128 MB 5G is the proposed next telecommunications standards beyond the current 4G standards. 5G planning aims at higher capacity than current 4G, allowing a higher density of mo

银狼的黎明 320

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

【分块】教主的魔法 @洛谷P2801/upcexam3138

时间限制: 1 Sec 内存限制: 128 MB 题目描述 教主最近学会了一种神奇的魔法,能够使人长高。于是他准备演示给XMYZ信息组每个英雄看。于是N个英雄们又一次聚集在了一起,这次他们排成了一列,被编号为1、2、……、N。 每个人的身高一开始都是不超过1000的正整数。教主的魔法每次可以把闭区间[L, R](1≤L≤R≤N)内的英雄的身高全部加上一个整数W。(虽然L=R时并

银狼的黎明 311

【搜索】传感器 @upcexam6023

时间限制: 1 Sec 内存限制: 128 MB 题目描述 SR最近新买了一款电子桌游 这个玩具内部是M个围成一圈的传感器。每个传感器都有开和关两种工作状态,分别用1和0表示。显然,从不同的位置触发沿顺时针方向连续检查K个传感器可以得到M个长度为K的01串。SR知道这M个01串应该是互不相同的。 而且这个桌游的设计很静谧,M会取到最大的可能值。现在SR已经了解到了K的值,他

银狼的黎明 288

【贪心】LIS @The 15th Zhejiang Provincial Collegiate Programming Contest E

传送门 题意要你构造一个序列,使得该序列的每个位置上的最长上升子序列的长度能构成给定的序列。 构造序列的元素要求还要求满足给定的上下界 solution 我们可以把给出的最长上升子序列的长度按升序排列,长度相同的按下标降序排列。 排完序后第一个数可以贪心的取其下界,同一层(即长度相同)的下标小的取值应该大于等于下标较大的取值 同时取值应该大于前一层下标最大且小于该位置的数 #def...

银狼的黎明 278
上一篇: 【动态规划】Column Addition @ICPC2017Tehran/upcexam5434
下一篇: 【分块】教主的魔法 @洛谷P2801/upcexam3138
乌拉尔银狼
博客等级 码龄10年 9粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值