编程介的小学生 2019-03-28 23:08 采纳率: 20.5%
浏览 199

如何才能计算这里的六边形的拆分的一个问题,采用C语言程序的设计的方式来计算的

Problem Description
There is a chessboard with n rows and n columns, every position is black or white. It is defined that c(x,y) means the color of the position in the xth row and the yth column, and it is guaranteed that c(x,y)=c(y,x)=c(x,n−y+1)=c(n−x+1,y) for any 1≤x,y≤n, which shows it is quite symmetry. Also because of this, only the colors of the positions (x,y) which satisfies x≤y≤⌊n+12⌋ are given, and the number of the given black position is t in total. Now HazelFan has a big cube with n layers and n rows and n lines, and its six sides are all same as the chessboard. For the three pairs of opposite sides, for each black position on one side, he will dig through the cube from the position straight to a black position on the other side. Please tell him after he destroys the cube, how many little cubes are left.

Input
The first line contains a positive integer T(1≤T≤5), denoting the number of test cases.
For each test case:
The first line contains two positive integers n,t(1≤n≤6×104,1≤t≤1.2×105).
The next t lines, each line contains two positive integers x,y(1≤x≤y≤⌊n+12⌋), denoting a given black position.

Output
For each test case:
A single line contains a nonnegative integer, denoting the answer.

Sample Input
2
3 1
2 2
5 2
2 3
3 3

Sample Output
20
76

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制