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 ...
随机推荐
- hibernate Day2 案例代码
1.编写实体类Person package com.icss.pojo; public class Person { private int uid; private String uname; pr ...
- log4j打印错误日志输出 利用sql取出的值放在list集合中,集合中的字段类型为映射类类型
public ServiceResult<List<KefuDetail>> MaxRespondtime(Date startDate,Date endDate, Strin ...
- myBatis-类型关联
1.一对多 collection <resultMap id="deptsql" type="Dept"> <id column=" ...
- JAVA-汉字转换成汉语拼音(pinyin4j-2.5.0-sources.jar)
在项目中,经常会使用汉语拼音,特别是把汉字转换成汉语拼音.下面给出一种常用的工具. 在使用该程序必须添加 pinyin4j-2.5.0-sources.jar包. import net.sourcef ...
- Solr6+IKAnalyzer分词环境搭建
环境要求 Zookeeper版本:zookeeper-3.4.8 JDK版本: jdk1.8. Solr版本:solr-6.4.1 Tomcat版本:tomcat8 ZK地址:127.0.0.1:21 ...
- BootStrap的基本使用
bootstrap 现成的css样式,直接调用类作用是快速写出页面又称UI框架Bootstrap中文网LESS是预处理器CSS预处理器定义了一种新的语言,基本的思想是用一种专门的编程语言,开发者只需要 ...
- python部分 + 数据库 + 网络编程
PS:附上我的博客地址,答案中略的部分我的博客都有,直接原标题搜索即可.https://www.cnblogs.com/Roc-Atlantis/ 第一部分 Python基础篇(80题) 为什么学习P ...
- PostgreSQL函数如何返回数据集 [转]
PostgreSQL函数如何返回数据集 以下主要介绍PostgreSQL函数/存储过程返回数据集,或者也叫结果集的示例. 背景: PostgreSQL里面没有存储过程,只有函数,其他数据库里的这两个对 ...
- 【CSS】纯css实现立体摆放图片效果
1. 元素的 width/height/padding/margin 的百分比基准 设置 一个元素 width/height/padding/margin 的百分比的时候,大家可知道基准是什么? 举 ...
- IE下的圆角
元素{ position: relative;/*必须*/ z-index: 10;/*必须*/ border-radius: 8px; -moz-border-radius: 8px; -webki ...