CodeForces 484B 数学 Maximum Value
2015-08-02 08:54
429 查看
很有趣的一道题,题解戳这。
代码君
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 200000 + 10; const int maxm = 1000000 + 10; int a[maxn], f[maxm]; int main() { int n; scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d", a + i); sort(a, a + n); n = unique(a, a + n) - a; int M = a[n-1]; for(int i = 0; i < n; i++) for(int j = a[i] + 1; j <= a[i+1]; j++) f[j] = a[i]; int ans = 0; for(int i = 0; i < n; i++) { for(int j = a[i] * 2; j <= M; j += a[i]) { ans = max(ans, f[j] % a[i]); } ans = max(ans, M % a[i]); } printf("%d\n", ans); return 0; }
代码君
相关文章推荐
- Integer Inquiry
- 使用rpmbuild来创建自己的RPM
- 使用rpmbuild来创建自己的RPM
- Replication_Error:Relay log write failure:could not queue event from master
- GUI做出渐进的颜色变化(随机指定颜色)
- GUI做出渐进的颜色变化(指定了颜色)
- Ubuntu 12.04 - 修改环境变量导致无法登录系统
- java编程之GUI小试
- iOS开发——UI进阶篇(十一)应用沙盒,归档,解档,偏好设置,plist存储,NSData,自定义对象归档解档
- iOS之UITextfield详细解析
- Message Queue under Qt5: zmq + nzmqt + qt
- poj 1141 Brackets Sequence
- powerbuilder 与sqlite3数据库
- 【Android UI】ListView系列二(自定义Adapter订阅新闻栏目)
- thinkpad T430s 在win8上安装ubuntu双系统(UEFI开启)
- UE删除空行
- UIKit框架-11.控制器跳转(UIStoryboardSegue)
- VK Cup 2015 - Finals, online mirror F - Clique in the Divisibility Graph dp
- 将UE添加到右键菜单
- request.getParameter() request.getAttribute()的区别