zoj 3768 Continuous Login

Pierre is recently obsessed with an online game. To encourage users to log in, this game will give users a continuous login reward. The mechanism of continuous login reward is as follows: If you have not logged in on a certain day, the reward of that day is 0, otherwise the reward is the previous day's plus 1.

On the other hand, Pierre is very fond of the number N. He wants to get exactly N points reward with the least possible interruption of continuous login.

Input

There are multiple test cases. The first line of input is an integer T indicates the number of test cases. For each test case:

There is one integer N (1 <= N <= 123456789).

Output

For each test case, output the days of continuous login, separated by a space.

This problem is special judged so any correct answer will be accepted.

Sample Input
4 20 19 6 9 
Sample Output
4 4 3 4 2 3 2 3 
Hint

20 = (1 + 2 + 3 + 4) + (1 + 2 + 3 + 4)

19 = (1 + 2 + 3) + (1 + 2 + 3 + 4) + (1 + 2)

6 = (1 + 2 + 3)

9 = (1 + 2) + (1 + 2 + 3)

 

题意:给出n求出最少要用多少等差数列的连续和组成。

sl:本以为是dp没想到n这么大,天啊,跳河,之后就没做,只敲了下dp代码看了看有没有什么规律。

打了表没看出来。后来才知道原来最终结果不超过3,再看看我的表确实如此。有表都没看出规律。

之后就是暴力枚举了。 时间复杂度是1e6刚好。

 外付打表代码。

 1 //water
 2 /*
 3 #include<cstdio>
 4 #include<cstring>
 5 #include<algorithm>
 6 #include<queue>
 7 #include<cmath>
 8 using namespace std;
 9 typedef long long LL;
10 const int inf = 0x3f3f3f3f;
11 const int MAX = 1e6+10;
12 int dp[MAX];
13 int main()
14 {
15     int n;
16     while(scanf("%d",&n)==1)
17     {
18         for(int i=0;i<MAX;i++) dp[i]=inf;
19         dp[1]=1; dp[0]=0;
20         for(int i=2;i<100;i++)
21         {
22             for(int j=1;j<100;j++)
23             {
24                 int t=(i-j+1)*(1+i-j+1)/2;
25                 if(t<=i)
26                 dp[i]=min(dp[i],dp[i-t]+1);
27             }
28         }
29         printf("%d\n",dp[n]);
30     }
31     return 0;
32 }
33 全然不超过3个
34 */
35 #include <cstring>
36 #include <algorithm>
37 #include <cstdio>
38 #include <map>
39 using namespace std;
40 const int MAX = 1e6+10;
41 map<int,int> val;
42 map<int,int> cnt;
43 
44 void init()
45 {
46     int start=1; int cur=1; int a=1;
47     while(start<=123456789)
48     {
49         val[cur]=start;
50         cnt[start]=cur;
51         a++;
52         start+=a;
53         cur++;
54     }
55 }
56 
57 int main()
58 {
59     int cas,n;
60     scanf("%d",&cas);
61     while(cas--)
62     {
63         val.clear(); cnt.clear();
64         init();
65         scanf("%d",&n);
66 
67         if(cnt[n])
68         printf("%d\n",cnt[n]);
69         else
70         {
71             int end=1; int flag=1;
72             while(val[end]<n) end++;
73             for(int i=1;i<=end;i++)
74             {
75                 if(val[n-val[i]])
76                 {
77                     flag=0;
78                     printf("%d %d\n",cnt[val[i]],cnt[n-val[i]]);
79                 }
80             }
81             for(int i=1;i<=end&&flag;i++)
82             {
83                 for(int j=end;j>=1&&flag;j--)
84                 {
85                     int t=n-val[j]-val[i];
86                     if(t>0)
87                     {
88                         if(val[t])
89                         {
90                             printf("%d %d %d\n",cnt[val[i]],cnt[val[j]],cnt[t]);
91                         }
92                     }
93                 }
94             }
95         }
96     }
97 
98     return 0;
99 }

转载于:https://www.cnblogs.com/acvc/p/3649206.html

【FPGA教程案例87】加解密1——基于FPGA的AES加解密算法verilog实现 DES已走到了它生命的尽头。56比特密钥实在太小,虽然三重DES可以解决密钥长度的问题,但是DES的设计主要针对硬件实现,而今在许多领域,需要用软件方法来实现它,在这种情况下,它的效率相对较低。1997年4月15日美国国家标准和技术研究所(NIST)发起征集AES(Advanced Encryption Standard)算法的活动,并成立了AES工作组。目的是为了确定一个非保密的、公开披露的、全球免费使用的加密算法,用于保护下一世纪政府的敏感信息。这里,我们对AES的基本原理进行介绍: 阅读详情

相关推荐

从零构建腾讯滑块验证码破解引擎:逆向工程与实战对抗

本文深入解析腾讯滑块验证码(原天御验证码)的防护机制,包括环境感知层、行为分析层和验证决策层的核心技术。通过JSVMP虚拟机保护、轨迹验证算法和动态加密体系,腾讯验证码实现了高效的人机识别。文章还提供了安全研究实践指南,涵盖环境模拟和验证码识别方案,并探讨了防御对抗的演进趋势与合规研究建议。

rl6adventurer的博客 831

ZOJ 3768 Continuous Login

题目链接:ZOJ 3768  Continuous Login 比赛时候

fobdddf的专栏 1288

VSCode配置C/C++开发环境:从零安装MinGW-w64并运行第一个C程序

在Windows系统上搭建C语言开发环境时,很多初学者混淆编辑器、编译器与调试器的分工,导致配置过程屡屡受挫。理解VSCode作为轻量级编辑器的定位,以及MinGW-w64提供的gcc编译器在源码编译中的核心作用,是顺利完成环境配置的关键。环境变量的正确设置直接影响gcc命令能否全局调用,而C/C++插件则赋予编辑器语法高亮与智能提示能力。通过安装VSCode、配置MinGW-w64、安装插件、汉化界面并运行一个最简单的hello.c程序,就能系统掌握这套开源工具链的完整工作流。无论是用于课程学习、算法练习

weixin_42531923的博客 533

ZOJ 3768 Continuous Login

Continuous Login Time Limit: 2 Seconds      Memory Limit: 131072 KB      Special Judge Pierre is recently obsessed with an online game. To encourage users to log in, this game will give users a

超越自我就是成功 445

Smart200 PLC实现Bool信号接通延时、关闭延时作用

解决Smart200 PLC时间继电器和脉冲扫描P或N不能重复使用的问题,用于Bool信号延时接通和延时关闭的作用,可调整时间基数

gk_121的博客 4319

【实战案例】IBM V3500存储控制器故障诊断与更换全流程解析

本文详细解析了IBM Storwize V3500存储控制器发生故障后的完整处理流程。通过还原真实故障现场,介绍了如何利用服务助手精准定位缓存模块损坏的根源,并逐步指导完成控制器备件准备、核心部件移植更换、系统上线同步及全面功能验证的全过程,为存储运维人员提供了一份实用的实战指南。

weixin_29269441的博客 549

ZOJ Problem Set - 3768 Continuous Login

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3768 打表暴力撸  最多只可能是三个数

可视化和机器学习 836

奇迹mu服务端DATA文件解析:从基础配置到高级玩法

本文深入解析奇迹MU服务端DATA文件的核心配置与高级玩法,涵盖基础设置、怪物AI系统、技能战斗机制、副本事件管理及物品商城定制。通过详细示例和实用技巧,帮助开发者掌握从经验倍率调整到动态事件触发的全方位配置方法,实现个性化的私服搭建与运营。

weixin_29254673的博客 532

ZOJ3768-Continuous Login

Continuous Login Time Limit: 2 Seconds      Memory Limit: 131072 KB      Special Judge Pierre is recently obsessed with an online game. To encourage users to log in, this game will give users

wang_128的博客 516

【目标检测】全局上下文感知的详解

目标检测中的全局上下文感知(Global Context Awareness)​是指模型在定位和识别目标时,能够有效利用图像中全局或大范围的上下文信息(如场景语义、目标间关系、空间布局等),而不仅仅依赖局部特征。这种能力显著提升了检测的鲁棒性,尤其是在复杂场景(如遮挡、小目标、密集目标)中表现突出。

浩瀚之水的专栏 649

代谢组数据分析(五):代谢组的功能富集分析

本文介绍了代谢组数据分析中的功能分析,包括代谢物富集分析、GSEA和ssGSEA方法。文章详细阐述了分析原理、应用背景、数据准备、统计方法以及结果解释,强调了在代谢通路和代谢物ID对应关系建立、差异代谢物筛选、富集程度计算等方面的关键步骤。通过这些方法,可以揭示差异代谢物在生物过程中的作用,为疾病研究和药物开发提供依据。

专注生信领域 5983

ZOJ 3768 Continuous Login(暴力或夹逼原理)

参考: http://blog.youkuaiyun.com/zhuhuangjian/article/details/23036139 http://blog.youkuaiyun.com/mid_kkks/article/details/23034401 本题预处理之后,就是一个背包问题,但是容量10e9,不能用背包。最后是判断出最多选择3个数,暴力解决或利用夹逼原理。 夹逼原理:2个数时,利用夹

冰 1524

DLMS/COSEM协议的理解体会

DLMS是通信协议,COSEM是电表建模规范。HDLC帧基本格式为0x7e......

一个bug是bug,多个bug能work 8315

ZOJ3768:Continuous Login(二分)

Pierre is recently obsessed with an online game. To encourage users to log in, this game will give users a continuous login reward. The mechanism of continuous login reward is as follows: If you have

ACM!荣耀之路! 2501

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

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

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

ZOJ3768 Continuous Login

Continuous Login Time Limit: 2 Seconds      Memory Limit: 131072 KB      Special Judge Pierre is recently obsessed with an online game. To encourage users to log in, this game will give users a

Jelly_acm的博客 511

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

zoj3768Continuous Login

链接 这题通过暴力可以看出最多不超过3 具体为什么。。等着看大牛的题解。 可以预处理出来两个数之和 用bool存下 然后枚举一个数 二分剩余数的位置就可以了 勉强可过 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm...

weixin_30268921的博客 125

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

ZOJ 3768 Continuous Login(找规律+哈希)

Pierre is recently obsessed with an online game. To encourage users to log in, this game will give users a continuous login reward. The mechanism of continuous login reward is as follows: If you have not logged in on a certain day, the reward of that day i

HJY 362

[迭代加深dfs] zoj 3768 Continuous Login

题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3768 Continuous Login Time Limit: 2 Seconds      Memory Limit: 131072 KB      Special Judge Pierre is recently obsessed

cc_again的专栏 1332

Continuous Login ZOJ - 3768 (暴力)

Continuous Login ZOJ - 3768 Pierre is recently obsessed with an online game. To encourage users to log in, this game will give users a c...

codeswarrior的博客 327

ZOJ 3768Continuous Login(找规律然后二分)

Continuous Login Time Limit: 2 Seconds      Memory Limit: 131072 KB      Special Judge Pierre is recently obsessed with an online game. To encourage users to log in, this game will give user

布生气 1783
上一篇: canvas画图
下一篇: 观察者模式的记录
weixin_30609331
博客等级 码龄11年 127粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值