HDU 1061 rightmost Digit

Source: Internet
Author: User

violence can not solve the problem, there are rules to follow, just look at the end of the number, the end of the number of the n-th square is a regular #include<cstdio>using namespaceStd; int Main () {  int N; int T;  while (scanf("%d",&T) !=Eof ) {  while( T--) {scanf("%d", &N); if (N%Ten ==0)Printf("0\n"); else if (N%Ten ==1)Printf("1\n"); else if (N%Ten ==2 ) {  if( N%4 ==0)Printf("6\n"); Else Printf("4\n"); }  Else if( N%Ten ==3 ) {  if(  ((N/Ten)%Ten)%2) ==0)Printf("7\n"); Else Printf("3\n"); }  Else if( N%Ten ==4)Printf("6\n"); else if (N%Ten ==5)Printf("5\n"); else if (N%Ten ==6)Printf("6\n"); else if (N%Ten ==7 ) {  if(  ((N/Ten)%Ten)%2) ==0)Printf("3\n"); Else Printf("7\n"); }  Else if( N%Ten ==8 ) {  if(  ((N/Ten)%Ten)%2) ==0)Printf("6\n"); Else Printf("4\n"); }  Else if( N%Ten ==9)Printf("9\n"); }}  return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 1061 rightmost Digit

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.