码迷,mamicode.com
首页 >  
搜索关键字:gcd and lcm    ( 5074个结果
费马小定理
费马小定理 定义 对于质数 $p$,当 $a$ 是一个与 $p$ 互质的整数时有: $$ a^{p 1}\equiv 1\quad (mod\; p) $$ 当然也可以化成: $$ a^p\equiv a\quad (mod\; p) $$ 证明 数学归纳法 1. 当 $a=0$ 时,显然成立。 2 ...
分类:其他好文   时间:2019-11-19 15:31:45    阅读次数:65
rac 关于RACScheduler的一点学习
RACScheduler 信号调度器,是一个线性执行队列,rac中的信号可以在RACScheduler上执行任务、发送结果,底层用GCD封装的。 rac中提供生成线程的几个方法: 1:scheduler,这是一个异步线程,不会对主线程造成堵塞,异步执行 2:immediateScheduler ,立 ...
分类:其他好文   时间:2019-11-16 17:26:47    阅读次数:83
$P2398\ GCD\ SUM$
$Description$ 求$\sum\limits_{i=1}^n\sum\limits_{j=1}^n gcd(i,j)$ $Solution$ 这种$gcd$计数的题一般思想是枚举$gcd$。 对于这道题,有一下几种做法,循序渐进 暴力:$O(n^2logn)$ 就是暴力枚举所有数求$gcd ...
分类:其他好文   时间:2019-11-13 16:37:14    阅读次数:84
iOS - dispatch_group
场景:分别异步执行2个耗时任务,然后当2个耗时任务都执行完毕后再回到主线程执行任务。这时候我们可以用到 GCD 的队列组 调用队列组的 dispatch_group_async 先把任务放到队列中,然后将队列放入队列组中。或者使用队列组的 dispatch_group_enter、dispatch_ ...
分类:移动开发   时间:2019-11-13 16:24:01    阅读次数:83
csp-s模拟95
T1: $$ \begin{align} & \sum _{i=0}^p \lfloor \frac{iq}{p} \rfloor \\ = & \sum_{i=0}^p \frac{iq iq \% p}{p} \\ = & \frac{ q \sum_{i=0}^p i \sum_{i=0}^p ...
分类:其他好文   时间:2019-11-12 09:26:31    阅读次数:78
[bzoj1385]Division expression
容易发现a2一定是分母,且容易做到其余都是分子,因此相当于判定a2能否整除a1*a3*……*an,不断让a2除以其与其他数的gcd即可(注意特判n=1) 1 #include<bits/stdc++.h> 2 using namespace std; 3 int t,n,s,x; 4 int gcd ...
分类:其他好文   时间:2019-11-11 12:42:37    阅读次数:76
【codeforces 19/11/06 div2】C. Tile Painting
1 #include <iostream> 2 using namespace std; 3 4 typedef long long LL; 5 6 LL gcd(LL a, LL b) 7 { 8 if (!b) return a; 9 return gcd(b, a % b); 10 } 11 ...
分类:其他好文   时间:2019-11-09 00:27:42    阅读次数:109
C. Tile Painting (定理:任意一个合数都能够写成两个质数的乘积) 《Codeforces Round #599 (Div. 2) 》
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate. The pa ...
分类:其他好文   时间:2019-11-09 00:25:44    阅读次数:99
数论(lcm)
CodeForces - 1154G You are given an array a consisting of n integers a1,a2,…,an . Your problem is to find such pair of indices i,j (1≤i<j≤n) that lcm( ...
分类:其他好文   时间:2019-11-08 16:22:08    阅读次数:88
CF1245 A. Good ol' Numbers Coloring(java与gcd)
题意:给定数字A和数字B,问是否满足gcd(A,B)==1。 思路:可以直接写函数gcd。也可以用大数自带的gcd功能。 代码1: /* @author nimphy @create 2019-11-06-12:07 about: */ import java.io.*; import java.u ...
分类:编程语言   时间:2019-11-06 13:09:49    阅读次数:87
5074条   上一页 1 ... 7 8 9 10 11 ... 508 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!