403 平方计数 思维+数论 [代码源][namomo spring camp]每日一题div1

基于CANoe的车载以太网测试 以太网测试 CANoe 阅读详情

题目链接
在这里插入图片描述

//acmer mxc
#include<bits/stdc++.h>
#define mst(s,x) memset(s,x,sizeof(s));
#define sr(x) scanf("%lld",&x); 
#define sr2(a,b) scanf("%d%d",&a,&b); 
#define sr3(a,b,c) scanf("%d%d%d",&a,&b,&c); 
#define sr4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d);
#define f(i,a,n) for(int i=a;i<=n;i++)
#define ff(i) for(int i=1;i<=n;i++)
#define sc(x) cout<<#x<<" : "<<x<<endl;
#define hh cout<<endl;
//#define int __int128
#define pii pair<int,int>
#define pb(x) push_back(x)
#define mk(a,b) make_pair(a,b)
#define ls(x) x<<1
#define rs(x) x<<1|1
#define fi first
#define se second
#define ll __int128
#define inf 0x3f3f3f3f
using namespace std;
inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') x=(x<<1)+(x<<3)+c-'0',c=getchar();
	return w==1?x:-x;
}
inline void write(ll x)
{
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}
//------------------------------------------------
#define int long long
#define dd double
const int N=1e6+5;
int n;
int a[N];
inline void solve()
{
	cin>>n;
	ff(i)
	{
		int now;
		scanf("%lld",&now);
		a[now]++;
	}
	int ans=0;
	for(int i=1;i<=1e6;i++) //枚举因子
	{
		for(int j=i;j<=1e6;j+=i)  
		{
			if(!a[j])continue;
			int x=min(j/i,i);
			int y=max(j/i,i);
			if((y-x)&1)continue;
			ans+=a[j]*a[(y-x)/2];
		}
	}
	cout<<ans/2<<endl;
	return;
}

//------------------------------------------------
signed main()
{
	clock_t c1=clock();
#ifdef LOCAL
    freopen("in.in","r",stdin);
    freopen("out.out","w",stdout);
#endif
//==================================
    int T=1;
	// cin>>T;
	for(int i=1;i<=T;i++)
	{
		solve();
	}
//==================================
end:
    cerr<< "Time used:" << clock() - c1 << endl;
	return 0;
}
vcpkg管理OpenCASCADE的5个高效技巧:从多版本共存到离线部署 本文详细介绍了使用vcpkg高效管理OpenCASCADE的5个实用技巧,包括多版本共存、性能优化、团队共享、CI/CD集成和离线部署。通过自动配置和版本控制,vcpkg显著简化了OpenCASCADE的开发环境管理,特别适合工业级CAD开发场景。 阅读详情

相关推荐

光学设计必看:如何用泽尼克系数优化镜头像差?从Zemax到实际案例解析

本文深入解析了如何利用泽尼克系数优化镜头像差,从理解其工程价值、解码软件报告,到在Zemax中主动设置优化目标。通过高倍显微物镜等实际案例,详细展示了如何通过分析泽尼克系数诊断问题,并实施针对性优化策略,从而实现对球差、彗差等像差的精准控制,提升光学设计的精细度和系统稳健性。

gg901的博客 1026

[Daimayuan]01序列2(C++,数学)

考察了组合数学和乘法逆元的知识

m0_74036684的博客 502

海康读码器上位机开发避坑指南:IDMVS客户端之外,如何用C# SDK搞定扫码、数据比对与实时控制?

本文详细介绍了如何利用海康读码器的C# SDK进行二次开发,实现从基础扫码到复杂工业控制的全流程解决方案。内容涵盖SDK架构解析、多设备管理系统构建、业务逻辑与设备控制实现,以及系统集成与性能优化等关键环节,为工业自动化领域的开发者提供实用指南。

weixin_30642561的博客 550

代码源每日一题Div2

思路:开始思路是找规律,for遍历每个数,然后插空什么的,结果问题就是有很多情况考虑不到.最后换了dfs解法,首先判断数量最多的数的数量和其他数数量总和的关系1.如果数量最多的数的数量大于其他数数量总和+1,那么一个隔一个插空都插不了,空不够,直接判失败2.如果数量最多的数的数量等于其他数数量总和+1,这个时候就只能把最大的这个数推进用于排序的数组3.如果数量最多的数的数量小于其他数数量总和+1,这个时候就是选合适的最小的数的时候了最后把用于排序的数组遍历输出一下,结束。

sign_river的博客 841

STM32H743实战(三)-- 时钟系统配置

本文详细讲解了STM32H743时钟系统的配置方法,重点解析了为何选择400MHz而非理论极限480MHz作为稳定运行的主频。通过STM32CubeIDE环境,手把手指导如何从外部晶振配置、电源电压设置到PLL锁相环参数调整,最终实现稳定可靠的400MHz系统时钟,并提供了代码验证与常见问题排查指南。

weixin_29164185的博客 368

Flotherm XT学习历程

大家好,通过半年的热仿真软件学习使用,最终发现最好用,最好上手的软件就是Flotherm XT,对新手非常友好,但由于软件近几年才发布,网上教程非常少,后面我将在这里持续分析软件使用心得,和大家一起学习。

xiaoredred的博客 6259

WEEK1 代码源每日一题Div2

代码源每日一题Div2

GuffRunetotem的博客 320

nvprof:CUDA编程性能分析工具

NVIDIA提供了具有高性能计算的GPU产品,如何检验硬件的实际性能,写出高效的CUDA代码让算力加速卡物尽其用,那可以通过其配套提供的“护城河”软件工具链来检验和帮助发挥GPU的性能:nvprof。如下,对于将8192个A,B向量进行向量加法运算,即C[i] = A[i] + B[i],当软件设置不同的blocknum, threadnum时候,CUDA执行kernel的时间是不同的。比如如下命令,可以看到程序tmp1的总体性能,下面一行是打印gpu的执行时间情况。

Briwisdom的博客 3384

代码源每日一题div2 异或和

每日一题?每日一抄!

weixin_62528401的博客 270

CH592F RISC-V蓝牙LED灯设计:WS2812B驱动与微信小程序控制

蓝牙低功耗(BLE)是嵌入式物联网设备主流无线通信技术,其核心在于协议栈轻量化、射频稳定性与外设协同调度。基于RISC-V内核的蓝牙SoC(如CH592F)凭借高集成度、低待机电流和免外部巴伦的射频设计,显著降低硬件复杂度与BOM成本;而WS2812B作为单线级联RGB LED,依赖微秒级精准时序,需借助定时器+DMA机制规避CPU干预,保障动态效果流畅性。该方案融合电容触摸交互、GATT服务自定义与微信小程序标准Bluetooth API对接,适用于智能照明、DIY彩灯及教学实践等场景,是BLE+LED实

weixin_31163455的博客 433

材料仿真软件:Materials Studio_(14).电学性质计算

设置计算参数,包括 k 点网格、交换相关泛函等。

kkchenjj的博客 1863

02字串2

/*问题描述   对于长度为6位的一个01串,每一位都可能是0或1,一共有64种可能。它的前几个是:   000000   000001   000010   000011   000100   有这些01串中,有一些01串的1的个数是奇数个,这部分01串的前几个是:   000001   000010   000100   000111   001000   001011   请按从小到大的顺序

liangguojunainia的专栏 930

(一)深入理解Bluez协议栈之蓝牙Mesh的支持(1/5)

BlueZ是Linux官方蓝牙协议栈。它是一个基于GNU General Public License (GPL)发布的开源项目,从Linux 2.4.6开始便成为Linux 内核的一部分。如果你是linux平台开发蓝牙的的工程师,肯定会接触过Bluez协议栈,hciconfig,hciattach,hciconfig等工具都是很好用的工具。

3321

代码源每日一题div2 特殊的正方形

输入n,输出n行n列的由+和.组成的正方形,其中最外面一圈全是+,第二圈全是.,...,对于第i圈,如果i是奇数,那么全是+,否则全是.。 输入格式 一行,一个整数n。 输出格式 n行,为满足题目要求的正方形。注意不要有行末空格。 样例输入 10 样例输出 ++++++++++ +........+ +.++++++.+ +.+....+.+ +.+.++.+.+ +.+.++.+.+ +.+....+.+ +.++++++.+ +........+ ++++++++++ 数据范围

听取WA声一片 352

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

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

代码源每日一题div2 巨大的牛棚

水

weixin_62528401的博客 341

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

代码-动态规划系列(更新中)

“抱佛脚”系列(代码部分); 所有代码均基于 Python3; 记号 LC{xx} 表示 Leetcode 第 xx 题,例如 LC20 表示 Leetcode 第 20题。 题目索引动态规划之套路高频题目LCxx - 编辑距离 动态规划之套路 高频题目 LCxx - 编辑距离 ...

weixin_39166189的博客 743

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

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

代码源每日一题div2 最长公共子序列

难题

weixin_62528401的博客 265

代码源每日一题div1 区间和

Daimayuan Online Judge 思路:构造图+bfs 告诉我们LiL_iLi​到RiR_iRi​连续元素的区间和,可以转换成Li−1L_i-1Li​−1到RiR_iRi​两点之间有条通路,那么问题转化成是否能找到一条通路从000走到nnn,bfsbfsbfs一遍即可 #include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

qq_53287227的博客 413

代码源每日一题Div.2 上帝的集合(优先队列,思维)

题目链接 题意 思路 若我们先只看操作1,3,是不是维护一个小顶堆即可; 但现在加上操作2,对所有的数加上一个 x,用堆没法轻易地改元素的值,这里可以类比线段树中的懒标记,每进行一次操作2,我们不是真的把这个 x 加到每一个数上,而是维护一个 lazy 标记,把 x 存起来,当进行操作3时,将 lazy 加到需要输出的数上即可; 但现在还有一个问题,假设当前堆中的序列为 1,2,3,lazy 为 2,现在要往堆中加一个 4,此时改 lazy 标记不应该作用于 4...

Gurenge的博客 411

【代码源每日一题Div2】505.新国王的游戏

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 代码源每日一题div2 #672新国王的游戏 前言 提示:这里可以添加本文要记录的大概内容: 提示:以下是本篇文章正文内容,下面案例可供参考 一、新国王的游戏 Problem Description 又到了 H 国国庆, 国王再次邀请 n 位大臣来玩有奖游戏。上次国庆被众臣吐槽国王小气后,国王决定今年大方点,改变游戏规则且不再参与游戏,免得被大臣们质疑。首先, 他让每位大臣在左、 右手上面分别写下一个正整数。然后让这 n 位大臣排成一.

m0_66327624的博客 4276

重复造轮子之RSA算法(一) 大素数生成

出于无聊, 打算从头实现一遍RSA算法 第一步, 大素数生成 Java的BigInteger里, 有个现成的方法   public static BigInteger probablePrime(int bitLength, Random rnd) {   bitLength是期望生成的素数的二进制位数, rnd是随机数发生器   函数注释表明, 这个方法的返回值为合数的概率为2^...

weixin_30242907的博客 2813

【BFS最短路】代码源每日一题div2 BFS练习1

BFS求最短路

weixin_62528401的博客 288

代码源div2 每日一题 思维+前缀和

三段式 将序列分成三段,每段和相等,不难发现,和其实就是总和/3 记总和为sum 由此我们可以利用前缀和计算序列和,找到和为sum/3和sum*2/3的点并记录下来 如果sum*2/3的点的下标大于sum/3的点的下标,那么就是组合法解 需要注意当所有元素为0的情况,这时的时间复杂度为,直接利用小学二年级学过的求和公式求和即可 #include<iostream> #include<vector> using namespace std; const int N

qq_44647370的博客 224

506 完美数 思维+数位 [代码源][namomo spring camp]每日一题div2

直接考虑有点难搞,仔细看他说是每个数位的和也是一个好数。 这个值从m∗min(a,b)m*min(a,b)m∗min(a,b)到 m∗max(a,b)m*max(a,b)m∗max(a,b) 也就是说我从这之间搞出来check一下就好了。 那么他们的和也就是从m个数中选i个数为b,m−i个数为am个数中选i个数为b,m-i个数为am个数中选i个数为b,m−i个数为a //acmer mxc #include<bits/stdc++.h> #define mst(s,x) memset(s,x,.

peacesir的博客 1464

代码源Div2刷题

【101】特殊的正方形(5.3) 链接:特殊的正方形 - 题目 - Daimayuan Online Judge 大意: 奇数圈是‘+’,偶数圈是‘.’ 解题思路: 模拟就好 代码: #include <bits/stdc++.h> using namespace std; char ch[103][103]; signed main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >&

Chral317的博客 511

每日之 Codeforces Round Div .2 D题打卡~

2020/02/07 Same GCDs CodeForces - 1295D 2020/02/08 Aroma's Search CodeForces - 1293D 2020/02/09 Irreducible Anagrams CodeForces - 1291D

The___Flash的博客 450
上一篇: 406 “Z”型矩阵 思维+树状数组 [代码源][namomo spring camp]每日一题div1
下一篇: 501 社交圈 离散化+贪心 [代码源][namomo spring camp]每日一题div1
while WA er
博客等级 码龄7年 14粉丝 114原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

while WA er

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值