hdu 4631 Sad Love Story(暴力)
来源:互联网 发布:linux recv函数 编辑:程序博客网 时间:2024/06/05 04:04
题目连接:hdu 4631 Sad Love Story
代码
#include <cstdio>#include <cstring>#include <set>#include <vector>#include <algorithm>using namespace std;typedef long long ll;typedef pair<ll, ll> pii;typedef set<pii>::iterator iter;ll ans;set<pii> G;ll get(ll x, ll y) { return x * x + y * y; }void solve (ll x, ll y) { iter it = G.lower_bound(make_pair(x, y)); for (iter i = it; i != G.end(); i++) { ll tmp = i->first - x; if (tmp * tmp >= ans) break; ans = min(ans, get(i->first - x, i->second - y)); } for (iter i = it; i != G.begin();) { i--; ll tmp = x - i->first; if (tmp * tmp >= ans) break; ans = min(ans, get(i->first - x, i->second - y)); }}int main () { int cas, n; scanf("%d", &cas); while (cas--) { G.clear(); scanf("%d", &n); ll Ax, Bx, Cx; ll Ay, By, Cy; scanf("%lld%lld%lld", &Ax, &Bx, &Cx); scanf("%lld%lld%lld", &Ay, &By, &Cy); ans = 1e18; ll x = Bx % Cx, y = By % Cy, ret = 0; for (int i = 1; i < n; i++) { G.insert(make_pair(x, y)); x = (x * Ax + Bx) % Cx; y = (y * Ay + By) % Cy; solve(x, y); ret += ans; } printf("%lld\n", ret); } return 0;}
0 0
- hdu 4631 Sad Love Story(暴力)
- hdu 4631 Sad Love Story (暴力set+剪枝)
- hdu 4631 Sad Love Story(最近点对+暴力)
- hdu 4631 Sad Love Story
- hdu - 4631 - Sad Love Story
- HDU-4631-Sad Love Story
- HDU 4631 Sad Love Story
- hdu 4631Sad Love Story
- HDU 4631 - Sad Love Story(最近点对)
- hdu 4631 Sad Love Story (STL+multiset)
- HDOJ 4631 Sad Love Story
- hdu 4631 Sad Love Story 多校第三场
- 2013 多校第三场 hdu 4631 Sad Love Story
- 【解题报告】HDU 4631 Sad Love Story 最短点距(动态)
- HDU Sad Love Story StL 暴搜
- Sad Love Story(hdu4631,模拟+set容器)
- 多校第三场 Hdu4631 Sad Love Story(最近点对)
- HDU4631 Sad Love Story(最近点对)转自网络
- Java 数据库 第五章 查询数据(DQL)
- hive中order by,sort by, distribute by, cluster by作用以及用法
- Eclipse插件集合及其安装方法
- 用栈来实现表达式的计算
- jquery关于select框的取值和赋值
- hdu 4631 Sad Love Story(暴力)
- 如何在C++中实现求两个整数的最大公约数和最小公倍数
- 在O(1)时间复杂度删除链表节点(LintCode)
- POJ 3126 Prime Path
- vlsm的划分
- 正试图在 os 加载程序锁内执行托管代码。不要尝试在 DllMain 或映像初始化函数内运行托管代码,这样做会导致应用程序挂起。问题的解决方法!
- 二十三种设计模式之行为型模式之模板方法
- lintcode:3 Sum
- 转义字符