#include<iostream>
#include<cmath>
using namespace std;
const int N=1e9+10;
int n,cnt,ans;
bool st[N];
int main(){
scanf("%d",&n);
int sum = 0;
while(n>0){
cnt++;
sum = ceil((double)n/3);
if(n%3 == 1 && ans == 0) ans = cnt;
n -= sum;
}
printf("%d %d",cnt,ans);
}
相关推荐
2023年 CSP-J T1 小苹果 T2 公路 题解
小苞想从站点 1 开车到站点 n,一开始小苞在站点 1 且车的油箱是空的。输出一行包含两个正整数,两个整数之间由一个空格隔开,分别表示小苞拿走所有苹果所需的天数以及拿走编号为 n 的苹果是在第几天。公路上每个站点都可以加油,编号为 i 的站点一升油的价格为 ai 元,且每个站点只出售整数升的油。对于所有测试数据保证:1≤n≤10^5,1≤d≤10^5,1≤vi≤10^5,1≤ai≤10^5。vn−1,分别表示站点间的距离。小苞想知道,多少天能拿完所有的苹果,而编号为 n 的苹果是在第几天被拿走的?
CSP-J 2023 复赛第1题:小苹果
● 由于数据规模为 10^9,所以一个一个枚举拿走的苹果必然会超时。不过可考虑一天一天枚举拿走的苹果。 ● 可推算出每天拿走的苹果数为 ceil(n/3),即每天拿走 (n+2)/3 个苹果,拿完后剩余 n-ceil(n/3) 个苹果。如果 n%3==1,那么第 n 个苹果此轮会被拿走。其中,ceil()为 C++ 中的向上取整函数。而floor()为 C++ 中的向下取整函数。
P9748 [CSP-J 2023] 小苹果
。
csp-j2023题解T1.小苹果
每天在拿的时候,小苞都是从左侧第 11 个苹果开始、每隔 22 个苹果拿走 11 个苹果。输出一行包含两个正整数,两个整数之间由一个空格隔开,分别表示小苞拿走所有苹果所需的天数以及拿走编号为 n 的苹果是在第几天。小苞想知道,多少天能拿完所有的苹果,而编号为 n 的苹果是在第几天被拿走的?小 Y 的桌子上放着 n 个苹果从左到右排成一列,编号为从 11 到 n。小苞是小 Y 的好朋友,每天她都会从中拿走一些苹果。小苞第一天拿走了编号为 11、44、77 的苹果。小苞第二天拿走了编号为 22、66 的苹果。
洛谷:P9748 [CSP-J 2023] 小苹果
小 Y 的桌子上放着n个苹果从左到右排成一列,编号为从1到n。小苞是小 Y 的好朋友,每天她都会从中拿走一些苹果。每天在拿的时候,小苞都是从左侧第1个苹果开始、每隔2个苹果拿走1个苹果。随后小苞会将剩下的苹果按原先的顺序重新排成一列。小苞想知道,多少天能拿完所有的苹果,而编号为n的苹果是在第几天被拿走的?
题解:洛谷 P5744 【深基7.习9】培训
题目涵盖了从基础到进阶的多种算法和数据结构,旨在为不同阶段的编程学习者提供一条清晰、平稳的学习提升路径。输入学员信息,请设计一个结构体储存这些学生信息,并设计一个函数模拟培训过程,其参数是这样的结构体类型,返回同样的结构体类型,并输出学员信息。行,每行首先输出一个字符串表示学生姓名,再往后两个整数,表示经过一年的培训后学员的年龄和他们今年的 NOIP 成绩。每行首先是一个字符串表示学员姓名,再是一个整数表示学员年龄,再是一个整数为去年 NOIP 成绩。经过为期一年的培训,所有同学的成绩都有所提高,提升了。
洛谷c++ P9748 [CSP-J 2023] 小苹果 AC代码
【代码】洛谷c++ P9748 [CSP-J 2023] 小苹果 AC代码。
【车辆动力学】专栏目录汇总
车辆动力学知识目录汇总
AcWing 5307. 小苹果
先进行时间复杂度的计算,每次拿的个数为ceil(n/3),所以近似计算。原题链接AcWing 5307. 小苹果。
数据结构:五岔路口交通管理红绿灯设计
我们可以知道这是一个“图”的着色问题,首先要考虑,为什么可行路线是13条?当然可以通过穷举得出,如果用公式:则是: 或者 因为一条路线必须包括一出一进两个方向 第一种答案的解法: 一、固定E为入口,则有C_4^1=4的可能; 二、除去E(因为E只有一个入向),剩下ABCD四个路口,然后因为C只有一个出方向,所以从剩下 的ABD中选择一个入口,即C_3^1; 三、再从剩下的三个出口任选
手机直连卫星上网,3GPP R17/R18到底做了哪些技术升级?(IoT/NR NTN详解)
本文深入解析了3GPP R17/R18标准中手机直连卫星上网的技术升级,重点介绍了IoT NTN与NR NTN两项关键技术。R17通过星历辅助补偿算法和多普勒频移控制,实现了智能手机直连卫星的突破;R18则进一步优化移动性、支持高频段和星上本地交换,提升用户体验。这些技术为物联网和5G/6G通信开辟了新可能。
【寒假每日一题·2024】AcWing 5307. 小苹果(补)
2024AcWing寒假每日一题。
火星遥感数据的获取与处理工具安装详解
有关火星遥感影像数据的那些事...
CSP-J 2023模拟原题--小苹果
每天在拿的时候,小苞都是从左侧第 1 个苹果开始、每隔 2 个苹果拿走 1 个苹果。随后小苞会将剩下的苹果按原先的顺序重新排成一列。输出一行包含两个正整数,两个整数之间由一个空格隔开,分别表示小苞拿走所有苹果所需的天数以及拿走编号为 n 的苹果是在第几天。小苞想知道,多少天能拿完所有的苹果,而编号为 n 的苹果是在第几天被拿走的?小 Y 的桌子上放着 n 个苹果从左到右排成一列,编号为从 1 到 n。小苞是小 Y 的好朋友,每天她都会从中拿走一些苹果。输入的第一行包含一个正整数 n,表示苹果的总数。
如何用Python实现SPEI指数计算?从数据准备到结果可视化完整指南
本文提供了一份完整的Python实现SPEI指数计算指南,涵盖从数据准备、潜在蒸散量计算到结果可视化的全流程。详细介绍了使用Thornthwaite方法计算PET、拟合三参数log-logistic分布以及标准化转换的核心算法,并提供了模块化代码和可视化方案,帮助用户构建可复用的干旱分析工具。
低速信号设计之 ESPI 篇
ESPI 是 Intel 推出的增强型串行外设接口,基于 SPI 发展而来,新增 Reset# 和 Alert# 信号,采用点对点主从通信模型,最高速率达 33MHz,支持半双工与 DMA 传输。 其物理接口含 10 条线路,通信协议分物理层、数据链路层等四层。布局布线需关注信号完整性、电源完整性,还得考虑与 SPI 的兼容性。 ESPI 广泛应用于计算机系统(连接 BIOS、电源管理器等)和工业控制领域,具有引脚少、功耗低等优势,但设计复杂且存在兼容性挑战。
6044 小苹果
TCTMC++oj平台题目
CodeQL查询时遇到报错:A fatal error occurred: Could not process query metadata for...如何解决?
🏆本文收录于 《全栈Bug调优(实战版)》 专栏,该专栏专注于分享我在真实项目开发中遇到的各类疑难Bug及其深层成因,并系统提供高效、可复现的解决思路和实操方案。无论你是刚入行的新手开发者,还是拥有多年项目经验的资深工程师,本专栏都将为你提供一条系统化、高质量的问题排查与优化路径,助力你加速成长,攻克技术壁垒,迈向技术价值最大化与职业发展的更高峰🚀!
陶陶摘小苹果
第一行包含10个100到200之间(包括100和200)的整数(以厘米为单位)分别表示10个小苹果到地面的高度,两个相邻的整数之间用一个空格隔开。hzk有个30厘米高的板凳,当她不能直接用手摘到小苹果的时候,就会踩到板凳上再试试。第二行只包括一个100到120之间(包含100和120)的整数(以厘米为单位),表示hzk把手伸直的时候能够达到的最大高度。现在已知10个小苹果到地面的高度,以及hzk把手伸直的时候能够达到的最大高度,请帮hzk算一下她能够摘到的小苹果的数目。假设她碰到小苹果,小苹果就会掉下来。
LinePhone3.2.7(android端最新版本) sip客户端
SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/
深度学习工具包 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');```[](https://bitdeli.com/free "Bitdeli Badge")
csp2023普及组复赛题解
t3-uqe 一元一次方程。t1-apple 小苹果。t4-bus 旅游巴士。t2-road 公路。
Statistics and Machine Learning Toolbox
Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具
CSP-J2023年复赛
【代码】CSP-J2023年复赛。
IDEA的使用指南
IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.
【C++ 真题】P9748 [CSP-J 2023] 小苹果
输出一行包含两个正整数,两个整数之间由一个空格隔开,分别表示小苞拿走所有苹果所需的天数以及拿走编号为。随后小苞会将剩下的苹果按原先的顺序重新排成一列。小苞是小 Y 的好朋友,每天她都会从中拿走一些苹果。小苞想知道,多少天能拿完所有的苹果,而编号为。个苹果从左到右排成一列,编号为从。每天在拿的时候,小苞都是从左侧第。特殊性质:小苞第一天就取走编号为。的苹果是在第几天被拿走的?小苞第一天拿走了编号为。小苞第二天拿走了编号为。小苞第三天拿走了编号为。小苞第四天拿走了编号为。小苞第五天拿走了编号为。
CSP-J(入门级)2023年T1小苹果
小 Y 的桌子上放着n个苹果从左到右排成一列,编号为从1到n。小苞是小 Y 的好朋友,每天她都会从中拿走一些苹果。每天在拿的时候,小苞都是从左侧第1个苹果开始、每隔2个苹果拿走1个苹果。随后小苞会将剩下的苹果按原先的顺序重新排成一列。小苞想知道,多少天能拿完所有的苹果,而编号为n的苹果是在第几天被拿走的?
C++ 小苹果
【代码】C++ 小苹果。
1601




被折叠的 条评论
为什么被折叠?



