zoukankan      html  css  js  c++  java
  • Codeforces Round #313 (Div. 1) A.Gerald's Hexagon

    Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to . Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.

    He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles.

    Input

    The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≤ ai ≤ 1000) — the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists.

    Output

    Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.

    Sample test(s)
    input
    1 1 1 1 1 1
    output
    6
    input
    1 2 1 2 1 2
    output
    13
    Note

    This is what Gerald's hexagon looks like in the first sample:

    And that's what it looks like in the second sample:

    题解:奇妙的做法。。。窝萌可以把它补成一个正三角形,然后减去三个小正三角形。。。

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cmath>
     4 #include<algorithm>
     5 #include<queue>
     6 #include<cstring>
     7 #define PAU putchar(' ')
     8 #define ENT putchar('
    ')
     9 using namespace std;
    10 int A[6];
    11 inline int read(){
    12     int x=0,sig=1;char ch=getchar();
    13     for(;!isdigit(ch);ch=getchar())if(ch=='-')sig=0;
    14     for(;isdigit(ch);ch=getchar())x=10*x+ch-'0';
    15     return sig?x:-x;
    16 }
    17 inline void write(int x){
    18     if(x==0){putchar('0');return;}if(x<0)putchar('-'),x=-x;
    19     int len=0,buf[15];while(x)buf[len++]=x%10,x/=10;
    20     for(int i=len-1;i>=0;i--)putchar(buf[i]+'0');return;
    21 }
    22 void init(){
    23     for(int i=0;i<6;i++)A[i]=read();
    24     int L=A[0]+A[1]+A[2];int S=L*L;
    25     S-=A[0]*A[0]+A[2]*A[2]+A[4]*A[4];
    26     write(S);
    27     return;
    28 }
    29 void work(){
    30     return;
    31 }
    32 void print(){
    33     return;
    34 }
    35 int main(){init();work();print();return 0;}
  • 相关阅读:
    nginx+upsync+consul 构建动态nginx配置系统
    服务容错保护断路器Hystrix之六:缓存功能的使用
    consul之:ACL配置使用
    Consul之:服务健康监测
    Consul实践指导-DNS接口
    Spring 整合Mybatis实例
    ORACLE SEQUENCE 具体解释
    python高速排序
    降阶法计算行列式方法有个地方有Bug(原文也已更正,此为更正后部分)
    MyBatis在Oracle中插入数据并返回主键的问题解决
  • 原文地址:https://www.cnblogs.com/chxer/p/4673114.html
Copyright © 2011-2022 走看看