Funky Numbers

大语言模型应用指南:幻觉和偏见问题 大语言模型应用指南:幻觉和偏见问题 1. 背景介绍 1.1 大语言模型的发展历程 1.1.1 早期的语言模型 1.1.2 Tr 阅读详情

        

As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are those that are representable as a sum of two triangular numbers.

A well-known hipster Andrew adores everything funky and cool but unfortunately, he isn't good at maths. Given number n, help him define whether this number can be represented by a sum of two triangular numbers (not necessarily different)!

Input

The first input line contains an integer n (1 ≤ n ≤ 109).

Output

Print "YES" (without the quotes), if n can be represented as a sum of two triangular numbers, otherwise print "NO" (without the quotes).

Sample 1

InputcopyOutputcopy
256
YES

Sample 2

InputcopyOutputcopy
512
NO

Note

In the first sample number .

In the second sample number 512 can not be represented as a sum of two triangular numbers.

这个题目的 话首先读题要读清楚, 使用两组数字来表示, 如果正常双重循环的话会超时, 所以分开写, 一个循环一个二分去写, 然后数的话要注意, 是sqrt(n * 2)因为n * ( n + 1) / 2, 所以代码如下:

#include <iostream>
#include <cmath>

using namespace std;

const int N = 1e09;
typedef long long int ll;

int main() {
    ll n, l, r, flag = 0;

    cin >> n;
    ll h = sqrt(n * 2);
    for (int i = 1; i < h; i++) {
        ll l = i, r = h;
        while (l <= r) {
            ll mid = (l + r) / 2;
            if (mid * (mid + 1) / 2 + i * (i + 1) / 2 > n) r = mid - 1;
            else if (mid * (mid + 1) / 2 + i * (i + 1) / 2 < n) l = mid + 1;
            else {
                flag = 1;
                break;
            }
        } 
        if (flag) break;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

ok, 润了

OSPF的7种状态,DR与BDR的基本概念,1、2、3、4、5、7类LSA解析,Stub、NSSA、Totally Stub、Totally NSSA的基本概念与配置 阅读详情

相关推荐

H2O到OmniH2O细节解读,人形机器人遥操作的技术演进与哲学

摘要:CMU何泰然团队相继发表的H2O和OmniH2O论文为人形机器人遥操作领域带来突破。H2O首创Sim-to-Data方法,通过形态/动作重定向和特权筛选处理人类动作数据,PPO算法实现基础控制。OmniH2O改进为教师-学生蒸馏框架,采用DAgger算法增强泛化能力,并消除对线速度输入的依赖。这两项工作从概念验证到工程落地,建立了一套完整的动作学习范式,为具身智能研究提供了重要参考。

CyanNoah的博客 1389

<cf> Funky Numbers

A. Funky Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As you very well know, this ye...

weixin_34240657的博客 333

5G核心网Framed Routing功能解析:基于PFCP的帧路由机制与多终端互联实践

5G核心网Framed Routing功能解析:基于PFCP的帧路由机制与多终端互联实践

大家好,我是码农老gou,一名专注于编程技术的程序员。在这个博客中,我将与大家分享我在工作和学习中的经验、见解以及一些实用的技术干货。 1467

Funky Numbers _CF192A

题目 As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are...

baidu_41907100的博客 329

TexGen模型导出ABAQUS inp文件时纱线材料属性缺失?5分钟快速修复指南

本文针对TexGen模型导出ABAQUS inp文件时纱线材料属性缺失的问题,提供了快速修复指南。通过手动编辑inp文件或使用Python脚本自动补全材料属性,帮助复合材料仿真工程师高效解决问题。文章还介绍了TexGen导出前的预防性设置和ABAQUS中的验证技巧,确保仿真分析的准确性。

qsc901234的博客 250

OpenWRT端口转发与NAT环回冲突的排查与解决

本文详细解析了OpenWRT路由器中端口转发与NAT环回功能冲突导致的内网访问故障。通过生活化类比阐明两者工作原理,提供从基础诊断到内核参数调整、LuCI选项配置及手动编写iptables规则的多套解决方案,并给出进阶排查思路,帮助用户彻底解决内网无法通过公网地址访问服务的常见问题。

weixin_29243279的博客 507

CodeForces - 192A Funky Numbers

As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are those...

薄荷糖 344

内网(极空间)搭建gitlab跳板机转发端口及域名配置

然后,回头尝试用内网地址+15022 clone,成功,用公网的ip+15222 clone失败,那就是定位到时nginx转发的问题了。首先想到的就是 git clone是通过ssh的22端口进行下载的,那就需要打通22端口,则又配置22端口的nginx转发。然后,我通过ssh命令,做一个端口转发,以实现内网穿透,将服务端口链接到跳板机上。然后穿透到阿里云服务器跳板机的端口,只能内网访问,需要用nginx做个转发,才能用公网ip进行访问。然后,如上,我的80端口,映射15080,22端口映射15022。

God丶Davide的博客 6074

codeForces 192A.Funky Numbers(二分)

题意:给你一个数字N,问你是否存在两个数字A,B使得N=A(A+1)2+B(B+1)2N=\frac{A(A+1)}{2}+\frac{B(B+1)}{2} 思路:上面这个式子等价于2N=A(A+1)+B(B+1)2N=A(A+1)+B(B+1),最简单想到的方法就是两重for循环枚举A,B的值从1−n√1-\sqrt{n},这样复杂度为n2n^2,看一下数据范围为1≤n≤1091\leq n\l

张松超的博客 716

地平线旭日X3派(RDK X3)从开箱到联网:新手避坑指南

本文为地平线旭日X3派(RDK X3)新手提供从开箱到联网的完整避坑指南。详细讲解了硬件识别、系统镜像烧录、串口调试(波特率921600)、有线/无线网络配置以及SSH/VNC远程访问等关键步骤,帮助开发者快速搭建稳定的开发环境,为后续AI应用部署扫清障碍。

weixin_29174385的博客 939

【WorkBuddy从入门到精通实战教程】使用手册 第 2 章 WorkBuddy的下载、安装、登录与更新

摘要:WorkBuddy官方下载地址为https://www.codebuddy.cn/work/,支持Mac和Windows系统,需根据设备自动匹配版本。安装时需核对发布者信息,Mac用户需拖入应用程序文件夹。登录支持微信扫码或手机号,公司电脑安装需IT授权。更新通过个人中心检查,遇到安装包损坏、登录失败或文件读写问题时,建议重新下载、检查网络/权限或联系官方支持。重要文件建议定期备份,避免直接操作原文件。(149字)

企鹅码农的专属播客,分享10多年的实战案例和经验解读,包含YOLO、RT-DETR、AI等各个工作领域。 1864

D - Funky Numbers (CodeForces - 192A)

D - Funky Numbers (CodeForces - 192A)  As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive inte

benniaoyizhi的博客 1199

文末含资料链接和视频讲解!YOLOv8集成CoordAtt注意力机制详细教程

本文详细介绍了如何在YOLOv8目标检测框架中集成CoordAtt注意力机制。首先解析了CoordAtt的工作原理,它通过分解式池化将位置信息嵌入到通道注意力中,相比传统注意力机制具有更好的空间信息保持能力。然后提供了PyTorch实现代码解析,包括自适应平均池化、Hard-Swish激活函数等关键实现细节。最后概述了YOLOv8架构,为后续集成CoordAtt提供基础。该教程适合具备深度学习基础的开发者,将理论与实践结合,帮助读者掌握这一目标检测优化技术。

FJN110的博客 266

A. Funky Numbers

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As you very well know, this year's funkiest numbers are so calle

无知的我 2404

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

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

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

codeForces 192A-Funky Numbers

As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are those...

点点滴滴 458

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Funky Numbers(二分)

As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are those...

doncoder的博客 509

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

题目:Funky Numbers(二分)

题目描述 As you very well know, this year’s funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are ...

H4ppyD0g的博客 466

CodeForces - 192A Funky Numbers ——二分

A. Funky Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As you very well know, this year's funkies

Lngxling的博客 407

Funky Numbers CodeForces - 192A

As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are tho

码农的一亩三分地 398

CodeForces - 192A Funky Numbers 【二分 】

题目链接:http://codeforces.com/problemset/problem/192/A Description As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as, wh...

MengHao的博客 270

CodeForces 192A Funky Numbers

As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are tho

CS33sun的博客 490

【CF#192 A】Funky Numbers (二分,查找,二元组)

题干: As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are ...

xuanweiace的博客 471

2013暑假集训B组训练赛第二场 - B - Funky Numbers

B -Funky Numbers Time Limit:2000MSMemory Limit:262144KB64bit IO Format:%I64d & %I64u SubmitStatusPracticeCodeForces 192A Description As you very well know, this year's ...

weixin_30449239的博客 169
上一篇: Oil Deposits
下一篇: 4 Values whose Sum is 0
kento_joyasa
博客等级 码龄5年 27粉丝 120原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值