栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 3889 Fractal Streets

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 3889 Fractal Streets

#include <cstdio>#include <cstdlib>#include <cmath>using namespace std;int n;int o1,o2;int xx1,xx2,yy1,yy2;int c[170];void find(int d,int t,int &wx,int &wy){ if (d==0) { wx = 0; wy = 0; return; } int delta = c[d-1] * c[d-1]; int xx,yy; if (delta>=t) { find(d-1,t,xx,yy); wx = yy; wy = xx; return; } t = t - delta; if (delta>=t) { find(d-1,t,xx,yy); wx = c[d-1]+xx; wy = yy; return; } t = t - delta; if (delta>=t) { find(d-1,t,xx,yy); wx = c[d-1]+xx; wy = c[d-1]+yy; return; } t = t - delta; if (delta>=t) { find(d-1,t,xx,yy); wx = c[d-1]-1-yy; wy = c[d]-1-xx; }}int main(){ int total,lin; scanf("%d",&total); c[0] = 1; for (int i = 1;i<=16;++i) c[i] = c[i-1] * 2; while (total>0) { --total; scanf("%d%d%d",&n,&o1,&o2); find(n,o1,xx1,yy1); find(n,o2,xx2,yy2); __int64 xx = xx2 - xx1,yy = yy2-yy1; __int64 ans = xx*xx+yy*yy; ans = sqrt(ans)*10+0.5; printf("%I64dn",ans); } return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/371057.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号