跳过正文
  1. Posts/

codeforces 560 C. Gerald's Hexagon (思维,几何)

·1 分钟

题意:给定一个六边形的六条边的长,问能分割成多少个单位正三角形.

分割不好办,那我们就反着来,先补成一个包含这个六边形的正三角形.

对于边长为a的正三角形,显然我们可以分割成a*a个单位正三角形

大正三角形的边长为连续的三条边的和

而要减掉的三个小三角形的边长为与之前连续的三条边的起始边的序号的奇偶性相同的三条边.

就是说如果求和的时候求的是前三条边,那么三个要减掉的小三角形的边长就是第一,三,五条边.

如果求和的时候求的是后三条边,那么三个要减掉的小三角形的边长就是第二,第四,第六条边.

 1/*************************************************************************
 2	> File Name: code/#313/C.cpp
 3	> Author: 111qqz
 4	> Email: rkz2013@126.com
 5	> Created Time: 2015年08月17日 星期一 07时13分54秒
 6 ************************************************************************/
 7
 8#include<iostream>
 9#include<iomanip>
10#include<cstdio>
11#include<algorithm>
12#include<cmath>
13#include<cstring>
14#include<string>
15#include<map>
16#include<set>
17#include<queue>
18#include<vector>
19#include<stack>
20#define y0 abc111qqz
21#define y1 hust111qqz
22#define yn hez111qqz
23#define j1 cute111qqz
24#define tm crazy111qqz
25#define lr dying111qqz
26using namespace std;
27#define REP(i, n) for (int i=0;i<int(n);++i)
28typedef long long LL;
29typedef unsigned long long ULL;
30const int inf = 0x7fffffff;
31int main()
32{
33    int a[10];
34    int b[5];
35    for ( int i = 1 ; i <= 6 ; i++)
36    {
37	cin>>a[i];
38    }
39    memset(b,0,sizeof(b));
40    for ( int i = 1 ; i <= 6 ; i++)
41    {
42	if (i<=3)
43	{
44	    b[0] = b[0] + a[i] ;
45	}
46	if (i%2==1)
47	{
48	    b[i/2+1] = a[i];
49	}
50    }
51    int ans;
52    ans = b[0]*b[0]-b[1]*b[1]-b[2]*b[2]-b[3]*b[3];
53    cout<<ans<<endl;
54
55	return 0;
56}

相关文章

hdoj 2436 Collision Detection

·2 分钟
Collision Detection # **Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1207 Accepted Submission(s): 367 **

hdu 5120 - Intersection

·2 分钟
题意:求两个相等的圆环的相交的面积…. 简单计算几何+容斥原理? 扇形面积公式记错调了半天2333333333 这题不难…倒是从学长那里收获了几点关于代码规范的问题… 听说了学长在北京区域赛时把PI定义错了一位结果一直WA的教训…. 以后还是写acos(-1)吧 局部变量和全局变量因为【想怎么其变量名想得整个人都不好了】就起成了一样的…被学长给了差评。 哦,对!还有一个就是发现了cmath库里有一个奇葩的函数名叫y1.。。。。。。。 —————————————————————————————————————————————— 竟然CE了 提示 error:pow(int,int) is ambiguous 看来我对语言的掌握程度还是不行呀…..

codeforces 560 B. Gerald is into Art (模拟)

·1 分钟
1/************************************************************************* 2 > File Name: code/cf/#313/B.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: Wed 22 Jul 2015 09:52:54 PM CST 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#define y0 abc111qqz 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define tm crazy111qqz 25#define lr dying111qqz 26using namespace std; 27#define REP(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef unsigned long long ULL; 30 31 int a1,b1,a2,b2,a3,b3; 32bool judge (int x2,int y2,int x3,int y3) 33{ 34 if (x2<=a1&&x3<=a1&&y2+y3<=b1) 35 return true; 36 if (y2<=b1&&y3<=b1&&x2+x3<=a1) 37 return true; 38 return false; 39} 40int main() 41{ 42 cin>>a1>>b1>>a2>>b2>>a3>>b3; 43 if (judge(a2,b2,a3,b3)||judge(b2,a2,a3,b3)||judge(b2,a2,b3,a3)||judge(a2,b2,b3,a3)) 44 { 45 puts("YES"); 46 } 47 else 48 { 49 puts("NO"); 50 } 51 52 return 0; 53}