2016微软探星夏令营在线技术笔试-#1342 : Full Binary Tree Picture
来源:互联网 发布:excel2016数据验证 编辑:程序博客网 时间:2024/06/14 00:46
http://hihocoder.com/problemset/problem/1342
题意理解:找规律,N=1,2是特殊的,之后的就有规律了:y坐标最下一层是2,4,2,4的差,最后就是差6, 12, 24.。。。x左边最下差2, 之后是3,6,12.。。。 一行一行的算,算某一行的时候,写出来最左边为第一项的等差数列通项,然后用f(y2) - f(y1 - 1)来算
急转弯:有点麻烦
算法:无
数据结构:无
from __future__ import print_function##'guilv'__author__ = 'hjkruclion'import sysimport mathdef read_int(): return list(map(int, sys.stdin.readline().split()))maxn = 50x = [[] for i in range(maxn)]y = [0 for i in range(maxn)]delt_y = [0 for i in range(maxn)]N, M = read_int()t = 3if N >= 2: delt_y[N - 2] = 2for i in reversed(range(0, N - 2)): delt_y[i] = t t *= 2y[0] = 0for i in range(1, N): y[i] = y[i - 1] + delt_y[i - 1]for _ in range(M): x1, y1, x2, y2 = read_int() x1, y1 = y1, x1 x2, y2 = y2, x2 if N == 1: if x1 <= 0 and y1 <= 0 and x2 >= 0 and y2 >= 0: print(1) else: print(0) elif N == 2: ans = 0 if x1 <= 0 and y1 <= 0 and x2 >= 0 and y2 >= 0: ans += 1 if y1 <= 2 and y2 >= 2: t1 = min(2, max(0, ((x1 - 1) + 6) // 4)) t2 = min(2, max(0, (x2 + 6) // 4)) ans += t2 - t1 print(ans) else: ans = 0 if y1 <= y[N - 1] and y2 >= y[N - 1]: t1 = min(2 ** (N - 2), max(0, ((x1 - 1) + 5 + 3 * (2 ** (N - 2))) // 6)) t2 = min(2 ** (N - 2), max(0, (x2 + 5 + 3 * (2 ** (N - 2))) // 6)) ans += t2 - t1 t1 = min(2 ** (N - 2), max(0, ((x1 - 1) + 1 + 3 * (2 ** (N - 2))) // 6)) t2 = min(2 ** (N - 2), max(0, (x2 + 1 + 3 * (2 ** (N - 2))) // 6)) ans += t2 - t1 # print(ans) t = 6 for i in reversed(range(1, N - 1)): t1 = min(2 ** i, max(0, ((x1 - 1) + t // 2 + 2 ** (i - 1) * t) // t)) t2 = min(2 ** i, max(0, (x2 + t // 2 + 2 ** (i - 1) * t) // t)) if y1 <= y[i] and y2 >= y[i]: ans += t2 - t1 t *= 2 if x1 <= 0 and y1 <= 0 and x2 >= 0 and y2 >= 0: ans += 1 # for i in range(0, N): # print(i, y[i]) print(ans)
阅读全文
0 0
- 2016微软探星夏令营在线技术笔试-#1342 : Full Binary Tree Picture
- 2016微软探星夏令营在线技术笔试
- 2016微软探星夏令营在线技术笔试题解(1)
- 2016微软探星夏令营在线技术笔试题解(2)
- 2016微软探星夏令营在线技术笔试题解(3)
- 2016微软探星夏令营在线技术笔试题解(4)
- Constraint Checker 2016微软探星夏令营在线技术笔试
- 2016微软探星夏令营在线技术笔试-#1341 : Constraint Checker
- 【在线笔试题解题报告系列】微软在线笔试之 2016微软探星夏令营在线技术笔试(时间:2016.07.17)
- 【hihocoder#1341】(微软探星夏令营在线技术笔试第一题)
- hihocoder 2017微软探星夏令营在线技术笔试 1534 Array Partition
- [HihoCoder]#1342 : Full Binary Tree Picture
- Full Binary Tree Picture——hihoCoder177
- [Hihocoder week177]Full Binary Tree Picture
- Full Binary Tree Picture hiho一下第 177 周
- [2016 微软预科生计划-探星夏令营在线测试2] Give My Text Back(字符串处理)
- [hihoCoder 1187] Divisors (微软预科生计划-探星夏令营在线测试)
- Full Binary Tree
- Java多线程系列--“基础篇”04之 synchronized关键字
- JBOD里都有什么?
- 十年存储生涯,十二年Dostor峰会
- 高性能计算场景IO优化一例
- 单卡12.8TB闪存卡到底怎么用?
- 2016微软探星夏令营在线技术笔试-#1342 : Full Binary Tree Picture
- Dstor存储峰会即将到来
- 为什么Raid对于某些场景没有任何提速作用?
- 冬瓜哥详解存储OS变迁
- 一杆老枪照玩次时代存储系统
- window10 64位系统 python3.5安装 pygame(looks like a file name ,but.....)
- 免费送书了!!
- 为什么说SAS、FC对CPU耗费比TCPIP+以太网低
- 第4周项目3.3 判断链表是否递增