[2016-04-14] [Codeforces] [630] D [Hexagons!]

Source: Internet
Author: User

  • Time: 2016-04-14-23:54:07 Thursday
  • Title number: [2016-04-14][codeforces][630][d][hexagons!]
  • The main idea of the topic: as the title of the figure, ask the outermost is n, the total number of lattice
  • Analysis:
    • Observation can be obtained, a n TableshownSectionNCircleof theLatticeChildnumber,the a n =6xN(N>0), a 0 =1 a n Table shown Section N Circle of the Lattice Child number , the a n = 6 x N ( N > 0 ) , a 0 = 1
    • So eventually aNs=1+6+ A+... ..+6xN=(3+3N)N+1 a n s = 1 + 6 + + ... + 6 x N = ( 3 + 3 n ) N + 1 ;
  • Problems encountered: Using the cumulative method will be T
  
 
  1. #include<cstdio>
  2. using namespace std;
  3. typedef long long ll;
  4. int main(){
  5. int n;
  6. scanf("%d",&n);
  7. ll ans = (3 + 3 *(ll)n)*n + 1;
  8. printf("%I64d\n",ans);
  9. return 0;
  10. }


From for notes (Wiz)

[2016-04-14] [Codeforces] [630] D [Hexagons!]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.