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;}
  • 相关阅读:
    dayⅦ:元组、字典的其他操作+集合类型
    dayⅥ:作业
    dayⅥ:字符串操作+列表操作
    dayⅣ:赋值运算+if判断
    dayⅣ:赋值运算+if判断作业
    dayⅢ、基本数据类型+运算符
    爬虫解析bs4
    爬虫请求库之requests库
    爬虫原理
    各主流Linux系统解决方案pip安装mysqlclient报错
  • 原文地址:https://www.cnblogs.com/chxer/p/4673114.html
Copyright © 2011-2022 走看看