很有趣的一道题,题解戳这

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; const int maxn = + ;
const int maxm = + ; int a[maxn], f[maxm]; int main()
{
int n; scanf("%d", &n);
for(int i = ; i < n; i++) scanf("%d", a + i);
sort(a, a + n);
n = unique(a, a + n) - a; int M = a[n-];
for(int i = ; i < n; i++)
for(int j = a[i] + ; j <= a[i+]; j++) f[j] = a[i]; int ans = ;
for(int i = ; i < n; i++)
{
for(int j = a[i] * ; j <= M; j += a[i])
{
ans = max(ans, f[j] % a[i]);
}
ans = max(ans, M % a[i]);
}
printf("%d\n", ans); return ;
}

代码君

CodeForces 484B 数学 Maximum Value的更多相关文章

  1. codeforces 484B B. Maximum Value(二分)

    题目链接: B. Maximum Value time limit per test 1 second memory limit per test 256 megabytes input standa ...

  2. Codeforces 484B Maximum Value(高效+二分)

    题目链接:Codeforces 484B Maximum Value 题目大意:给定一个序列,找到连个数ai和aj,ai%aj尽量大,而且ai≥aj 解题思路:类似于素数筛选法的方式,每次枚举aj,然 ...

  3. CodeForces 484B Maximum Value (数学,其实我也不知道咋分类)

    B. Maximum Value time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  4. Codeforces 484B Maximum Value(排序+二分)

    题目链接: http://codeforces.com/problemset/problem/484/B 题意: 求a[i]%a[j] (a[i]>a[j])的余数的最大值 分析: 要求余数的最 ...

  5. Maximum Value(CodeForces - 484B)

    Maximum Value Time limit 1000 ms Memory limit 262144 kB You are given a sequence a consisting of n i ...

  6. CodeForces 484B Maximum Value

    意甲冠军: a序列n(2*10^5)数字  问道a[i]>=a[j]如果是  a[i]%a[j]最大值是多少 思路: 感觉是一道挺乱来的题-- 我们能够将ans表示为a[i]-k*a[j]  这 ...

  7. codeforces 484b//Maximum Value// Codeforces Round #276(Div. 1)

    题意:给一个数组,求其中任取2个元素,大的模小的结果最大值. 一个数x,它的倍数-1(即kx-1),模x的值是最大的,然后kx-2,kx-3模x递减.那么lower_bound(kx)的前一个就是最优 ...

  8. CodeForces 173C Spiral Maximum 记忆化搜索 滚动数组优化

    Spiral Maximum 题目连接: http://codeforces.com/problemset/problem/173/C Description Let's consider a k × ...

  9. CodeForces 173C Spiral Maximum (想法、模拟)

    Spiral Maximum Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Sub ...

随机推荐

  1. 转 怎样解读10046 trace (tkprof 的结果 )

    set autot on SQL> set autotraceUsage: SET AUTOT[RACE] {OFF | ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ ...

  2. 类加载机制 + Classloader.loadClass(String name)和Class.forName(String name)

    Classloader.loadClass(String name)和Class.forName(String name)的区别 Java的类在jvm中的加载大致分为加载,链接或者叫link(里面包含 ...

  3. [已读]JavaScript DOM高级程序设计

    08年出版,但是不得不说内容很好,正如书名,重点是DOM部分,看的还蛮早的,这本,记得是13年.

  4. 将Object转换成Dictionary方法

    如果Object是Dictionary类型,直接返回 如果Object是NameValueCollection类型,则添加到Dictionary里 如果Object是Hashtable类型,添加到Di ...

  5. Java常用函数式接口--Consumer接口使用案例

    第一种方式: 第二种方式:

  6. AJPFX关于线程创建的方式

    创建线程的第一种方式:继承Thread ,由子类复写run方法. 步骤: 1,定义类继承Thread类: 2,目的是复写run方法,将要让线程运行的代码都存储到run方法中: 3,通过创建Thread ...

  7. nodejs中的异步回调机制

    1.再次clear Timer定时器的作用 setTimeOut绝非是传统意义上的“sleep”功能,它做不到让主线程“熄火”指定时间,它是用来指定:某个回调在固定时间后插入执行栈!(实际执行时间略长 ...

  8. Does Little'law really applicable to apply performance model now?

    上次提到Little定律, 我也解释过它跟另外一个公式有一些内在的关系,但是其实我自己对LL在当前复杂架构系统中到底是怎么应用的也没有完整的想法,于是我在Linkedin上把这个问题抛了出来,没有想到 ...

  9. 使用 Azure 创建网络文件系统

    本快速入门介绍了如何使用 Azure 文件存储实现网络文件共享.在本教程中完成的所有操作均符合 1 元试用条件. 本快速入门介绍了如何使用 Azure 文件存储实现网络文件共享.在本教程中完成的所有操 ...

  10. JS 操作对象 事件 样式

    1.获取标记对象 css 1 - class 2 - id 3 - 标记选择器 js 1 - class 2 - id 3 - 标记 4 - name + document.getElementByI ...