B. Nastya Studies Informatics time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so s…
有增长姿势了 如果a * b == lcm * gcd 那么a和b为lcm因数  这个我之前真不知道emm... #include <bits/stdc++.h> #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; typedef long long LL; , INF = 0x7fffffff; LL gcd(LL a, LL b) { ?a:gcd(b, a%b); } int main() { LL l, r, x…
Nastya Studies Informatics   time limit per test 1 second   memory limit per test 256 megabytes   input standard input output standard output   Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent,…
Nastya Studies Informatics time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she…
http://codeforces.com/problemset/problem/992/B  题意: 给你区间[l,r]和x,y 问你区间中有多少个数对 (a,b) 使得 gcd(a,b)=x lcm(a,b)=y ,如果a,b交换位置就是不同的数对 思路: 根据lcm(最小公倍数) 的定义 y=a*b/x; 也就是说 x∗y=a∗b : 那么 ,我们发现a,b一定为y的因数,所以我们枚举y的每个因子就可以,我们只要用log(y)的复杂度暴力算每一个因数就可以 , 然后对于每个因子当做a, b…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 因为gcd(a,b)=x 所以设a = nx b = mx 又有ab/gcd(a,b)=lcm(a,b)=y 则nmx = y 即n(m*x)=y 所以枚举y的因子n 算出对应的y/n是否为x的倍数 如果是的话,则算出n,m的具体值 然后对于a<b的,答案加两次 如果a==b,答案加一次,a>b不加(避免重复计数) [代码] #include <bits/stdc++.h> #define ll long long usin…
大意: 给定序列a, 单点更新, 询问是否存在a[i]等于s[i-1], s为a的前缀和, a非负 考虑到前缀和的单调性, 枚举从1开始前缀和, 找到第一个大于等于s[1]的a[i], 如果相等直接输出. 若不满足则只能在a[i]的右侧, 此时前缀和为s[i], 至少为s[1]的两倍, 故最多进行log次. 具体实现的话, 线段树维护a与s的差, 二分找第一个非负即可, 复杂度$O(nlog^2n)$. #include <iostream> #include <algorithm>…
B. Nastya Studies Informatics time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so s…
A. Nastya and an Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nastya owns too many arrays now, so she wants to delete the least important of them. However, she discovered that this…
Nastya and an Array 输出有几种不同的数字 #pragma comment(linker, "/STACK:102400000,102400000") #ifndef ONLINE_JUDGE #include "stdafx.h" #else #include<bits/stdc++.h> #endif using namespace std; typedef long long lint; typedef vector<int…