Co-prime

lammps案例:Cu三点弯曲模拟 大家好,我是小马老师。 本文分享一个Cu弯曲的案例。 本案例参考三点弯曲实验,三点弯曲试验是将试样放在弯曲装置上,在试样上加载进行弯曲试验,直到达到规定的弯曲程度或发生断裂。 模拟原理是在z方向固定两侧端点,在x和y方向不固定,模拟左右两个支撑点,中间压块向下运动实现弯曲。 初始结构: 运行结果为: 模拟的重点是使用fix setforce命令压住左右两端,使其不能沿z轴上下移动,但是又不能在xy方向限制其移动。 压块的运动方式比较简单,给其一个下压的速度即可。 为防止压块变形,使用setforce命 阅读详情

Problem Description

Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N.
Two integers are said to be co-prime or relatively prime if they have no common positive divisors other than 1 or, equivalently, if their greatest common divisor is 1. The number 1 is relatively prime to every integer.

Input

The first line on input contains T (0 < T <= 100) the number of test cases, each of the next T lines contains three integers A, B, N where (1 <= A <= B <= 1015) and (1 <=N <= 109).

Output

For each test case, print the number of integers between A and B inclusive which are relatively prime to N. Follow the output format below.

Sample Input

2
1 10 2
3 15 5

Sample Output

Case #1: 5
Case #2: 10


思路:用a~b的长度减去1~10中与n不互素的个数(容斥定理)

代码如下:

#include<stdio.h>
#include<string.h>
long long p[1000];
int main()
{
    long long a,b,c,d,k,t,n,m,s,x,cnt,sum;
    scanf("%lld",&t);
    for(int i=1;i<=t;i++)
    {
        scanf("%lld %lld %lld",&a,&b,&n);
        cnt=0;
        sum=b-a+1;
        x=n;
        for(int j=2;j*j<=x;j++)
        {
            if(x%j==0)
            {
                p[cnt++]=j;
                while(x%j==0)
                    x=x/j;
            }
        }
        if(x>1)
        p[cnt++]=x;
        for(long long j=1;j<(1<<cnt);j++)
        {
            long long s=1,l=0;
            for(int k=0;k<cnt;k++)
            {
                if(j&(1<<k))
                {
                    l++;
                    s=s*p[k];
                }
            }
            s=b/s-(a-1)/s;
            if(l%2)
            sum=sum-s;
            else
            sum=sum+s;
        }
        printf("Case #%d: %lld\n",i,sum);
    }
    return 0;
}


QGraphicsView通过鼠标操作来绘制图元 在Visio和MindManager等类似的图元操作软件中,很多时候我们会通过鼠标操作来添加自定义的图元。这里就介绍一下如何在QT的图形视图框架中通过鼠标绘制来添加图元。 阅读详情

相关推荐

4.无限共轭距柯克物镜设计——zemax学习笔记

无限共轭cooker物镜

fly_daerm的博客 1601

Min-Max容斥总结

下用max⁡k(S)\max_k(S)maxk​(S)表示集合SSS的第kkk大元素(k⩽∣S∣k\leqslant|S|k⩽∣S∣),max⁡(S)\max(S)max(S)表示集合SSS的最大元素,最小同理 算法 min-max容斥是一种用于求出给定集合第kkk大(小)元素的容斥,通常在比较元素大小较为困难时使用 有一给定集合SSS,现希望求出max⁡k(S)\max_k(S)maxk​(S),考虑构造系数ana_nan​满足: max⁡k(S)=∑∅≠T⊆Sa∣T∣min⁡(T)\max{_k}(

一只蒟蒻的博客 3213

「API取数」FDL获取金蝶云星空的单据数据

本文介绍了如何使用FDL实现金蝶云API取数以及如何有效应对复杂的API数据处理场景。

oOBubbleX的博客 2034

min-max容斥学习笔记

min-max容斥(极值反演) \(\min-\max\)容斥是说一个这样的式子: \[ \max\{S\}=\sum_{T\subseteq S}(-1)^{|T|+1}\min\{T\} \] \[ \min\{S\}=\sum_{T\subseteq S}(-1)^{|T|+1}\max\{T\} \] 其中\(\min\{S\}\)表示\(S\)集合中的最小元素,\(\max\{S\}\)...

weixin_30654583的博客 268

把 ABAP writable CDS view entity 讲透:从只读建模到可写模型的 ABAP CDS 新能力

摘要:SAP引入的writable CDS view entity突破了传统CDS视图只读的限制,允许通过ABAP SQL直接进行数据修改。该特性通过WRITABLE关键字定义,使CDS视图成为与数据库表同等级别的可写对象。其核心价值在于为数据集成、中间层同步等场景提供结构化写入入口,但需注意不应绕过业务规则。最佳实践建议保持底层表结构简单映射,避免复杂变形。这一特性标志着CDS从单纯消费模型向双向数据交互能力的演进,为ABAP开发提供了新的数据边界设计思路。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1314

【DRAM存储器三十五】LPDDR4介绍--主要技术特性之VREF training,为什么要做VREF training?

详述DDR4、LPDDR4需要做vref training的原因和训练过程

highman110的博客 2923

Co-prime (HDU-4135)(容斥原理)

Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N. Two integers are said to be co-prime or relatively prime if they have no comm...

菜鸡的博客 374

ExpressLRS(ELRS)接收机技术全景:从历史演进、技术底层到产业生态全解析——上

ExpressLRS(ELRS)是一种由全球开源社区驱动的双向射频遥控链路协议栈,其接收机作为核心终端,承担信号接收解调、遥控指令解析、飞控数据交互与遥测回传等关键功能。自2018年问世以来,ELRS凭借极致性能、低成本、开放生态和强兼容性,从航模DIY方案发展为消费级无人机领域的事实标准,并逐步渗透工业级场景。 ELRS接收机采用模块化分层架构,支持2.4GHz和900MHz双频段,通过LoRa、FLRC、FSK多调制模式实现低延迟与远距离平衡。其核心技术包括自适应跳频抗干扰、TDD双向链路和极简数据包。

bother3000的博客 305

Min-Max容斥小结

介绍 对于一个集合 U={a1,a2,a3,...,an}U=\{a_1,a_2,a_3,...,a_n\}U={a1​,a2​,a3​,...,an​},我想要知道其中的 max⁡\maxmax,但是很不好求,那么就可以通过Min-Max容斥转化为求出它所有子集中的 min⁡\minmin。 正题 一切的魔术来源于这个简单的式子: max⁡{U}=∑S⊆U(−1)∣S∣+1min⁡{S} \max\{U\}=\sum_{S\subseteq U} (-1)^{|S|+1} \min\{S\} max{U}

a_forever_dream的博客 1071

11.11华为OD机试真题 新系统 - 管线同类区段归并 (Java/Py/C/C++/Js/Go)

11.11华为OD机试真题 新系统 - 管线同类区段归并 (Java/Py/C/C++/Js/Go)

算法大师! 162

微信小程序 - 下单账号和支付账号不一致,请核实后再支付(微信小程序或微信H5页面/微信公众号网页支付时报错:“下单账号和支付账号不一致,请核实后再支付”,买家微信支付时提示错误)详细排查和解决方案!

微信支付出现 “下单账号与支付账号不一致,请核实后再支付”微信小程序下单账号与支付账号不一致不让支付,微信公众号网页 微信H5页面JS-SDK支付时出现错误:下单账号和支付账号不一致,请核实后再支付,openId导致的微信中“下单账号和支付账号不一致”原因及解决办法,调用统一下单所传openId与实际支付用户的openId不一致,微信支付jssdk报错,检查了没有不一致依然报错怎么办,微信支付下单账号和支付账号不一致,请核实后再支付,微信支付功能用JSAPI支付,H5页面负责下单并支付jsapi,微信调起支

🏆 前端领域优质创作者 5337

HDU 4135(容斥原理)

Co-prime Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8792Accepted Submission(s): 3474 Problem Description Given a number N, you ar...

wdaoyuanjun的博客 482

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

HDU 4135 Co-prime

HDU 4135 Co-prime 传送门题意给出一个区间的左右端点,再给出区间里的一个数,然后需要求出在区间中有几个数与给定的数互素。思路暴力求解肯定是过不去的,会超时,这里需要利用容斥原理。假设当前m=12,n=10。第一步:求出给出数的质因子:2,3,5;第二步:(1,m)中是n的因子的倍数当然就不互质了(2,4,6,8,10)->n2\dfrac{n}{2} 6个,(3,6,9,12)->

obsidian的博客 245

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

F - Co-prime(数学,容斥原理)

F - Co-prime Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N. Two integers are said to be co-prim...

dengyan1183的博客 163

hdu 4135_Co-prime(容斥原理)

/*  hdu 4135(容斥原理) Hot~~招聘——亚信科技,巴卡斯(杭州),壹晨仟阳(杭州),英雄互娱(杭州) (包括2016级新生)除了校赛,还有什么途径可以申请加入ACM校队? Co-prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S

持之以恒_fighting 405

[ICPC2020 Nanjing R] K Co-prime Permutation(构造&思维)

用空格分隔,表示一个满足给定的约束的排列。如果没有存在的排列则输出。请不要在行末输出多余的空格,否则你的答案可能会被认为是错误的。的情况,然后对于相邻的两个数字进行颠倒,那么其肯定互质。如果有多个有效的答案,输出任意一个均可。

陈进士学习的博客 816

Co-prime HDU - 4135

HDU _4135 Co_prime  Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N. Two integers are said to be co-prime or relativel

ZJLORD 413

[容斥原理] hdu 4135 Co-prime

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4135 Co-prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1176    Accepted Submis

cc_again的专栏 1283

【HDU】4135 Co-prime 容斥原理

传送门:【HDU】4135 Co-prime

poursoul 718

K Co-prime Permutation亚洲区域赛(南京)

K Co-prime Permutation 这是一道具有迷惑性的题目 先上原题: 样例1: 输入 5 3 输出 1 4 5 2 3 样例2: 输入 1 0 输出 -1 题目意思: 这个题目的大概意思就是给你两个数n,k,n代表着这个序列的个数而且这个序列的每个数都小于等于n。然后就是这个序列中恰好只有 k 个 gcd(i,a(i)) = 1;其他的gcd(i,a(i)) != 1; 这个题意看起来很难,而且***样例具有迷惑性***(这也是这次比赛最大的收获)。 k正常的情况下 **我们先考虑前

zhizu_zdp的博客 615

HDU-4135-Co-prime(容斥)

HDU-4135-Co-prime 传送门 这道题是容斥~ 题目大意:给你一个区间[a, b],和一个数n,让你求区间[a, b]范围内的与n互质的数有多少个。 解题思路:我们看看数据范围,a和b的区间范围达到了1e15,n的数据范围达到了1e9。t次询问范围在100以内。 我们把这道题的思路与前缀和结合起来想一想。求区间[a, b]与n互质的数字,那我们转化成求[1, b]区间与 暴力肯定是不行...

qq_44624316的博客 237

HDU - 4135 Co-prime

题目连接 HDU - 4135 Co-prime 题意 输入a,b,n,要求区间[a,b]中与n互质的数的个数(1&lt;=a&lt;=b&lt;=10^15 ; 1&lt;=n&lt;=10^9)。 思路 判断两个数是否互质,首先想到辗转相除法,然而这里的a,b相当大,枚举a,b间的每一个数并判断和n是否互质必然超时。 既然判断两个数互质方法单一,那么我们可以从反面考虑,首先...

Herobrine的博客 187

杭电Co-prime(4135)(容斥+质因数分解)

杭电Co-prime(4135)(容斥+质因数分解)

m0_56280274的博客 224

Co-prime(容斥定理)

Co-prime Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N. Two integers are said to be co-prime or relatively prime if they hav...

双木林的博客 789
上一篇: The Boss on Mars
下一篇: Sum
绿蚁.r
博客等级 码龄10年 4粉丝 37原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值