【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 [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
随机推荐
- GIS+=地理信息+容器技术(1)——容器技术概述
-------------------------------------------------------------------------------------- Blog: http ...
- T2: 一种能累积计算积分的EC2实例类型
假设您打算在AWS云端执行一个小型的 Web Server,或是一个小型的数据库,平时并没有大量的工作负载.在绝大多数时间里,您的实例并不须要消耗大量的CPU资源.可是,再不怎么受欢迎的博客也可能会有 ...
- 基于Dynamic Proxy技术的方法AOP拦截器开发
在面向对象编程中,会用到大量的类,并且会多次调用类中的方法.有时可能需要对这些方法的调用进行一些控制.如在权限管理中,一些用户没有执行某些方法的权限.又如在日志系统中,在某个方法执行完后,将其执行的结 ...
- Codeforces 115A- Party(DFS)
A. Party time limit per test 3 seconds memory limit per test 256 megabytes input standard input outp ...
- 控制台中使用SetTimer的提醒
SetTimer是设置定时器,每隔一段时间执行一个操作,原型如下 UINT_PTR SetTimer( HWND hWnd, // 窗口句柄 UINT_PTR nIDEvent, // 定时器ID,多 ...
- luogu2431 正妹吃月饼
题目大意 求一个正整数集合\(K\),使得\(\sum_{k\in K}2^k\in[A,B]\),且\(|K|\)最大.\(A,B\)大小在long long范围内. 思路 \(\sum_{k\in ...
- vs2015+ffmpeg开发环境配置【转】
本文转载自:http://blog.csdn.net/hustlx/article/details/51014307 1.在http://ffmpeg.zeranoe.com/builds/ 下载最新 ...
- day63-webservice 05.发布接口实现类的webservice
package com.rl.cxf.client; import com.rl.inter.HI; import com.rl.inter.HIService; public class HiInt ...
- 以SqlHelper为例论面向对象中封装的使用(续)
上文以SqlHelper为例说明了面向对象中封装的好处,但是上文只是简单封装,考虑下面代码的情况: public static Activate GetByCode(string code) { Li ...
- tensorflow冻结层的方法
其实常说的fine tune就是冻结网络前面的层,然后训练最后一层.那么在tensorflow里如何实现finetune功能呢?或者说是如何实现冻结部分层,只训练某几个层呢?可以通过只选择优化特定层的 ...