【codeforces 805A】Fake NP
【题目链接】:http://codeforces.com/contest/805/problem/A
【题意】
问你在l..r这个区间内的所有数字;
对于每个数的因子;
出现次数最多的是哪一个;
【题解】
正常情况下;
求l..r内的出现的因子数
可以转化成1..l-1和1..r两个部分来求;
后者减去前者就好;
都需要枚举2的倍数在1..x里面有多少个,3的倍数在1..x里面….
即x/2个和x/3个…
以此类推;
显然每次都是2的倍数最多啦;
但是有例外吧
就是l==r的时候,且l为奇数的时候;
这时没有2的倍数了;
则这个时候直接输出l就好;
【Number Of WA】
0
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
int l,r;
int main()
{
//freopen("F:\\rush.txt","r",stdin);
ios::sync_with_stdio(false),cin.tie(0);//scanf,puts,printf not use
cin >> l >> r;
if (l==r && (l&1))
{
cout << l << endl;
}
else
cout << 2 << endl;
return 0;
}
【codeforces 805A】Fake NP的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【66.47%】【codeforces 556B】Case of Fake Numbers
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【Codeforces 258E】 Devu and Flowers
[题目链接] http://codeforces.com/contest/451/problem/E [算法] 容斥原理 [代码] #include<bits/stdc++.h> usin ...
- 【codeforces 807C】Success Rate
[题目链接]:http://codeforces.com/contest/807/problem/C [题意] 给你4个数字 x y p q 要求让你求最小的非负整数b; 使得 (x+a)/(y+b) ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
随机推荐
- JS遮罩层
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- pom.xml出现web.xml is missing and <failOnMissingWebXml> is set to true解决方案
提示信息应该能看懂.也就是缺少了web.xml文件,<failOnMissingWebXml>被设置成true了. 搜索了一下,Stack Overflow上的答案解决了问题,分享一下. ...
- [SPOJ 30669] Ada and Trip
[题目链接] https://www.spoj.com/problems/ADATRIP/ [算法] 直接使用dijkstra堆优化算法即可 [代码] #include<bits/stdc++. ...
- 【NOIP 2009】 靶形数独
[题目链接] https://www.luogu.org/problemnew/show/P1074 [算法] 搜索 + 剪枝 [代码] #include<bits/stdc++.h> u ...
- HttpServletRequest对象小结
当客户端通过HTTP协议访问服务器时,请求所有信息都封装在HttpServletRequest对象中,可通过它获取到请求的所有信息,其常用方法如下: getRequestURL方法返回客户端发出请求时 ...
- Redis五种数据类型及应用场景
MySql+Memcached架构的问题 实际MySQL是适合进行海量数据存储的,通过Memcached将热点数据加载到cache,加速访问,很多公司都曾经使用过这样的架构,但随着业务数据量的不断增加 ...
- A - Dubstep
Problem description Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep mus ...
- Npgsql使用入门(二)【实用助手类】
数据库映射的实体类: public class Test { public long TestID { get; set; } public string Name { get; set; } pub ...
- DataTable转Json就是这么简单(Json.Net DLL (Newtonsoft))
之前JSON转DataTable可以见我之前的随笔 链接Json转换成DataTable 之前没有用过DataTable,之后随着需求的叠加发现需要将DataTable转换成Json.因为之前都是用的 ...
- 1.Ventuz 介绍
Ventoz能做什么? Ventuz是一款实时图文包装内容创作.制作和播出控制软件.Ventuz专注于高端视听内容的制作,包括交互展示和大型活动.视频墙.广播电视在线包装及演播室舞台及灯光控制等领域. ...