CodeForces 484B 数学 Maximum Value
很有趣的一道题,题解戳这。
#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的更多相关文章
- codeforces 484B B. Maximum Value(二分)
题目链接: B. Maximum Value time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces 484B Maximum Value(高效+二分)
题目链接:Codeforces 484B Maximum Value 题目大意:给定一个序列,找到连个数ai和aj,ai%aj尽量大,而且ai≥aj 解题思路:类似于素数筛选法的方式,每次枚举aj,然 ...
- CodeForces 484B Maximum Value (数学,其实我也不知道咋分类)
B. Maximum Value time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Codeforces 484B Maximum Value(排序+二分)
题目链接: http://codeforces.com/problemset/problem/484/B 题意: 求a[i]%a[j] (a[i]>a[j])的余数的最大值 分析: 要求余数的最 ...
- Maximum Value(CodeForces - 484B)
Maximum Value Time limit 1000 ms Memory limit 262144 kB You are given a sequence a consisting of n i ...
- CodeForces 484B Maximum Value
意甲冠军: a序列n(2*10^5)数字 问道a[i]>=a[j]如果是 a[i]%a[j]最大值是多少 思路: 感觉是一道挺乱来的题-- 我们能够将ans表示为a[i]-k*a[j] 这 ...
- codeforces 484b//Maximum Value// Codeforces Round #276(Div. 1)
题意:给一个数组,求其中任取2个元素,大的模小的结果最大值. 一个数x,它的倍数-1(即kx-1),模x的值是最大的,然后kx-2,kx-3模x递减.那么lower_bound(kx)的前一个就是最优 ...
- CodeForces 173C Spiral Maximum 记忆化搜索 滚动数组优化
Spiral Maximum 题目连接: http://codeforces.com/problemset/problem/173/C Description Let's consider a k × ...
- CodeForces 173C Spiral Maximum (想法、模拟)
Spiral Maximum Time Limit:3000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Sub ...
随机推荐
- android开发学习 ------- debug 和 release版本执行结果不同
在debug上测试成功的,release上测试不成功,就想着怎么将 release 版本进行调试一下.还好 Android Studio 3.0是可以进行调试apk的 可以显示log,自己看自己的逻辑 ...
- WPF 控件树
WPF控件树按照基类进行分类,记录下来便于编写自定义控件时查阅 RangeBase范围控件 Thumb拖到控件 TextBoxBase文本控件 ItemControl组控件 ContrentContr ...
- Spring Boot运行原理
概述 本文主要写了下Spring Boot运行原理,还有一个小例子. Spring4.x提供了基于条件来配置Bean的能力,而Spring Boot的实现也是基于这一原理的. Spring Boot关 ...
- @RequestParam和@ResponseBody注解的区别(转)
@RequestParam 用来处理Content-Type: 为 application/x-www-form-urlencoded编码的内容.(Http协议中,如果不指定Content-Type, ...
- this,call,apply,bind浅析
在JS中,this指向是一个难点,在本文中讲解几种常见的this指向问题,并介绍一下call,apply,bind这三个函数的用法. 一.常见的this指向情况 首先要明白一点就是,函数里面才会有th ...
- Android View 背景选择器编写技巧
在项目中选择器的使用是非常多的,以下是本人在项目中的一些常用的背景选择器的写法 带边框下划线背景选择器效果图: 上面布局中放了10个CheckBox,然后设置了CheckBox的背景图片位,背景选择器 ...
- fiddler+willow问题总结
本文纯属用来记录自己学习过程中遇到的坑,如有朋友也遇到,可移步到这里查看是否为该问题导致. fiddler 安装不用说了,到官网直接去下载,自行下载最新版本 willow下载地址:http://qzo ...
- 洛谷 P1531 I Hate It
题目背景 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.这让很多学生很反感. 题目描述 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的 ...
- Hibernate学习之简单应用
前言:博主在学到Spring的时候,要开始做项目了,突然觉得好像有点虚,之前学过的Hibernate框架的简单应用好像又忘记了.所以返回来,做个小笔记. 简单来讲,Hibernate框架是利用对象-关 ...
- spring_boot入门
核心: 控制反转(Inversion of Control-IOC)和依赖注入(Dependency Injection-DI) Spring中两者是相同的, 控制反转是用依赖注入实现的. 这里, 依 ...