CF#805 A. Fake NP(水题)

A. Fake NP
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Tavak 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
Note

Definition of a divisor: https://www.mathsisfun.com/definitions/divisor-of-an-integer-.html

The first example: from 19 to 29 these numbers are divisible by 2{20, 22, 24, 26, 28}.

The second example: from 3 to 6 these numbers are divisible by 3{3, 6}.


题意:在 [ l , r ] 区间内找出每个数的因子中出现最多的数,若有多个则输出任意一个。显然只要 l != r ,答案就为 2。


#include <bits/stdc++.h>
using namespace std;

const int N = 10 + 10;
int l, r;

int main()
{
    while(scanf("%d%d", &l, &r) == 2)
    {
        if(l == r) printf("%d\n", l);
        else printf("2\n");
    }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
请解释此段代码class GATrainer(): def __init__(self, input_A, input_B): self.program = fluid.default_main_program().clone() with fluid.program_guard(self.program): self.fake_B = build_generator_resnet_9blocks(input_A, name="g_A")#真A-假B self.fake_A = build_generator_resnet_9blocks(input_B, name="g_B")#真B-假A self.cyc_A = build_generator_resnet_9blocks(self.fake_B, "g_B")#假B-复原A self.cyc_B = build_generator_resnet_9blocks(self.fake_A, "g_A")#假A-复原B self.infer_program = self.program.clone() diff_A = fluid.layers.abs( fluid.layers.elementwise_sub( x=input_A, y=self.cyc_A)) diff_B = fluid.layers.abs( fluid.layers.elementwise_sub( x=input_B, y=self.cyc_B)) self.cyc_loss = ( fluid.layers.reduce_mean(diff_A) + fluid.layers.reduce_mean(diff_B)) * cycle_loss_factor #cycle loss self.fake_rec_B = build_gen_discriminator(self.fake_B, "d_B")#区分假B为真还是假 self.disc_loss_B = fluid.layers.reduce_mean( fluid.layers.square(self.fake_rec_B - 1))###优化生成器A2B,所以判别器结果越接近1越好 self.g_loss_A = fluid.layers.elementwise_add(self.cyc_loss, self.disc_loss_B) vars = [] for var in self.program.list_vars(): if fluid.io.is_parameter(var) and var.name.startswith("g_A"): vars.append(var.name) self.param = vars lr = 0.0002 optimizer = fluid.optimizer.Adam( learning_rate=fluid.layers.piecewise_decay( boundaries=[ 100 * step_per_epoch, 120 * step_per_epoch, 140 * step_per_epoch, 160 * step_per_epoch, 180 * step_per_epoch ], values=[ lr, lr * 0.8, lr * 0.6, lr * 0.4, lr * 0.2, lr * 0.1 ]), beta1=0.5, name="g_A") optimizer.minimize(self.g_loss_A, parameter_list=vars)
最新发布
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值