hdu 4631 Sad Love Story 多校第三场
来源:互联网 发布:丽新网络盒子 编辑:程序博客网 时间:2024/06/08 18:36
用一个set保存所有点,按照x排序的顺序,然后根据插入点离x从远到近更新结果,一旦不可能更新了就跳掉。
没想到这么暴力也可以过。。。
#include <set>#include <cstdio>#include <cstring>#include <string>#include <iostream>#include <algorithm>#include <iterator>#include <map>#include <cmath>#include <cstdlib>using namespace std;typedef __int64 lld;typedef pair<lld,lld> PII;#define MP(a,b) make_pair((a),(b))#define inf 12345678912345678LLset<pair<lld,lld> >s;int main(){ int T; scanf("%d",&T); while(T--) { lld n,ax,bx,cx,ay,by,cy; s.clear(); scanf("%I64d %I64d %I64d %I64d %I64d %I64d %I64d",&n,&ax,&bx,&cx,&ay,&by,&cy); lld x=0,y=0,xi,yi; xi=(x*ax+bx)%cx; yi=(y*ay+by)%cy; x=xi,y=yi; s.insert(MP(x,y)); lld res=0; lld ans=inf; for(int i=1;i<n;i++) { set<PII>::iterator it,tm; xi=(x*ax+bx)%cx; yi=(y*ay+by)%cy; if(s.count(MP(xi,yi))) break; s.insert(MP(xi,yi)); it=s.lower_bound(MP(xi,yi)); for(tm=it,tm++;tm!=s.end();tm++) { lld tx=(*tm).first,ty=(*tm).second; if((tx-xi)*(tx-xi)>=ans) break; else { lld tmp=((tx-xi)*(tx-xi)+(ty-yi)*(ty-yi)); if(ans>tmp) ans=tmp; } } for(tm=it,tm--;it!=s.begin();tm--) { lld tx=(*tm).first,ty=(*tm).second; if((xi-tx)*(xi-tx)>=ans) break; else { lld tmp=((tx-xi)*(tx-xi)+(ty-yi)*(ty-yi)); if(ans>tmp) ans=tmp; } if(tm==s.begin()) break; } x=xi,y=yi; res+=ans; } cout<<res<<endl; } return 0;}
- hdu 4631 Sad Love Story 多校第三场
- 2013 多校第三场 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
- 多校第三场 Hdu4631 Sad Love Story(最近点对)
- hdu 4631 Sad Love Story (STL+multiset)
- hdu 4631 Sad Love Story(暴力)
- HDOJ 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 Sad Love Story StL 暴搜
- Sad Love Story(hdu4631,模拟+set容器)
- HDU 多校第三场
- 错误 5172:文件“*.mdf”的文件头不是有效的数据库文件头。PageAudit 属性不正确
- JSP文件下载
- hdu 1599 find the mincost route_最小环
- Android学习札记15:对Android中View绘制流程的一些理解
- CC430学习笔记(四)——时钟系统
- hdu 4631 Sad Love Story 多校第三场
- hdu2544最短路
- DUILIB创建菜单窗口
- 关于localhost 与Ip访问的区别
- 【框架-MFC】MFC- Dialog(chenlu1):风格与主界面同步
- Android编程心得-在任意类中获取当前屏幕宽高
- OllyDbg、IDA、WINDBG
- UITableView滑动删除
- linux CS8900不能设置MAC地址的解决方法