Fake NP (Codeforces
来源:互联网 发布:玩dnf网络冲突怎么办 编辑:程序博客网 时间:2024/05/18 01:08
题目链接:
http://codeforces.com/problemset/problem/805/A
A. Fake NP
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputTavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.
You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times.
Solve the problem to show that it's not a NP problem.
Input
The first line contains two integers l and r (2 ≤ l ≤ r ≤ 109).
Output
Print single integer, the integer that appears maximum number of times in the divisors.
If there are multiple answers, print any of them.
Examples
input
19 29
output
2
input
3 6
output
3
题目大意:
输入两个数,输出 以这两个数为边界的区间内 所有数 出现次数最多的 因子(除1外),如果有多种情况,输出任一个。
解题思路:
在一个区间内,偶数的个数大于其它类型数的个数。但还需要分两种情况:第一种情况:如果输入的两个数相等,那么输出这两个数中的任一个即可;第二种情况:输出 2
代码:
#include<iostream>using namespace std;int main(){ long long int l,r; while(cin>>l>>r) { if(l==r) cout<<l<<endl; else cout<<2<<endl; } return 0;}
阅读全文
0 0
- Fake NP (Codeforces
- CodeForces 805A Fake NP
- Codeforces 805A Fake NP
- codeforces 411div2-fake NP
- Codeforces Round #411 (Div. 2) A. Fake NP
- Codeforces Round #411 A.Fake NP (思维题)
- Codeforces Round #411 (Div. 2) A. Fake NP【水题】
- 小白题解 Codeforces 805A Fake NP
- Codeforces805 A. Fake NP
- CF411div2 A. Fake NP
- A. Fake NP
- A. Fake NP
- 805A Fake NP
- Codeforces Round #411 A.Fake NP【数论有关因数结论+经验】
- CodeFroces 805A Fake NP
- Codeforces Round #411(A. Fake NP; B. 3-palindrome; C. Find Amir; D.Minimum number of steps)
- CF#805 A. Fake NP(水题)
- CodeForces 805AFake NP
- Java中关于String类型的10个问题
- JS日期
- JavaSE-6
- 【nyoj116】士兵杀敌二(线段树)
- 如何实现线程的同步
- Fake NP (Codeforces
- 电力系统项目学习(1)--项目介绍
- Asp.net SignalR 指定用户消息推送简单示例
- Leetcode-5: Longest Palindromic Substring
- Seal Report使用教程(二)——项目文件
- 不使用第三个值,实现两个变量的互换
- 网络编程(一)--URL
- 数据库视频|自己不懂的点汇总
- Android widght之PopupWindow