zoukankan      html  css  js  c++  java
  • CDZSC_2015寒假新人(2) 数学 C

    Description

    Given a positive integer N, you should output the most right digit of N^N. 
     

    Input

    The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. 
    Each test case contains a single positive integer N(1<=N<=1,000,000,000). 
     

    Output

    For each test case, you should output the rightmost digit of N^N. 
     

    Sample Input

    2 3 4
     

    Sample Output

    7 6

    Hint

     In the first case, 3 * 3 * 3 = 27, so the rightmost digit is 7. In the second case, 4 * 4 * 4 * 4 = 256, so the rightmost digit is 6. 
             
     

     题目有规律, 找到规律即可。

     
     1 #include <cstdio>
     2 int Map[2][10] = {{0,1,4,7,6,5,6,3,6,9},{0,1,6,3,6,5,6,7,4,9}};
     3 int main()
     4 {
     5     int t,n;
     6     scanf("%d",&t);
     7     while (t--)
     8     {
     9         scanf("%d",&n);
    10         printf("%d\n",Map[(n/10)%2][n%10]);
    11     }
    12     return 0;
    13 }
    View Code
  • 相关阅读:
    SQL的增删改查
    SQL语句的分类
    创建新DB和新用户&DBeaver连接
    jQuery css() 方法:设置或返回被选元素的一个或多个样式属性
    jQuery
    jQuery
    jQuery
    jQuery
    jQuery
    jQuery
  • 原文地址:https://www.cnblogs.com/LiuACG/p/4246126.html
Copyright © 2011-2022 走看看