ACDream 1024:Triangles
来源:互联网 发布:怎么用u盘安装ubuntu 编辑:程序博客网 时间:2024/05/22 19:26
Triangles
Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)
Submit Statistic Next Problem
Problem Description
How many triple of points
xA,yA,xB,yB,xC,yC∈Z xA,yA,xB,yB,xC,yC∈Z0≤xA,xB,xC<n,0≤yA,yB,yC<m 0≤xA,xB,xC<n,0≤yA,yB,yC<mS△ABC∉Z S△ABC∉Z? (S△ S△ denotes the area of triangle)
Input
Two integers
(
Output
The only integer denotes the number possible triples, modulo
Sample Input
2 2
Sample Output
24
Hint
There are
假设三角形的3的顶点分别为P1(x1,y1),P2(x2,y2),P3(x3,y3)
则向量a 就可以表示为(x2-x1,y2-y1)
向量b 就可以表示为(x3-x1,y3-y1)
根据二维向量叉积的运算
∣a×b|=(x2-x1)(y3-y1) - (y2-y1)(x3-x1)
则这个三角形的面积
S = |((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1) ) / 2|
所以,算出每一个点四种情况的个数,然后深搜各个点的各种情况。
代码:
#pragma warning(disable:4996)#include <iostream>#include <functional>#include <algorithm>#include <cstring>#include <vector>#include <string>#include <cstdio>#include <cmath>#include <queue>#include <stack>#include <deque>#include <ctime>;#include <set>#include <map>using namespace std;typedef long long ll;#define INF 0x3fffffffffffffffconst ll mod = 1e9 + 7;const int maxn = 1e4 + 5;ll n, m, res;ll c[2][2];//c[0][0]代表都是偶数的情况数void dfs(int num, int x1, int y1, int x2, int y2, int x3, int y3){if (num == 4){if (((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) % 2 != 0){res += (((c[x1 % 2][y1 % 2] * c[x2 % 2][y2 % 2])%mod * c[x3 % 2][y3 % 2]))%mod;res %= mod;}}else{int i, j;for (i = 1; i <= 2; i++){for (j = 1; j <= 2; j++){if (num == 1){dfs(num + 1, i, j, 3, 3, 3, 3);}else if (num == 2){dfs(num + 1, x1, y1, i, j, 3, 3);}else if (num == 3){dfs(num + 1, x1, y1, x2, y2, i, j);}}}}}void solve(){ll i, j, k, x, y;scanf("%lld%lld", &n, &m);for (i = 0; i < 2; i++){for (j = 0; j < 2; j++){if (i == 0)x = (n - 1) / 2 + 1;elsex = n / 2 ;if (j == 0)y = (m - 1) / 2 + 1;elsey = m / 2;c[i][j] = (x*y) % mod;}}res = 0;dfs(1, 3, 3, 3, 3, 3, 3);printf("%lld\n", res);}int main(){//#ifndef ONLINE_JUDGE//freopen("i.txt", "r", stdin);//freopen("o.txt", "w", stdout);//#endifsolve();return 0;}
0 0
- ACDream 1024:Triangles
- ACdream Triangles
- ACdream 1067:Triangles
- acdream 1067 Triangles (结论)
- ACDream 1067 Triangles
- ACdream 1067:Triangles
- ACdream 1024
- Triangles
- Triangles
- Triangles
- Triangles
- Triangles
- Triangles
- ACdream
- Acdream
- ACdream
- ACdream
- ACdream
- 【hdu5015】233 Matrix——矩阵快速幂
- Ubuntu unity 桌面正常工作在VNC上
- 【BZOJ2741】FOTILE模拟赛 L
- oracle中使用物化视图实现表的同步
- Mac OS X 下开启PHP
- ACDream 1024:Triangles
- Material Design Theme
- Simple Game
- 单链表的创建/测长/打印
- mysql系列3-mysql主从同步
- mybaits之动态sql
- SSM-如何验证事务是否生效
- 初探react-native Hello World
- 阿里云服务器Web项目配置发布全过程(一)