博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 1061 hdoj 1061
阅读量:4123 次
发布时间:2019-05-25

本文共 802 字,大约阅读时间需要 2 分钟。

Rightmost Digit

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14448    Accepted Submission(s): 5617
Problem 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
234

#include<stdio.h>
main()
{
    int n,k,i,result;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&k);
        result=1;
        if(k%4==0)
        {
            for(i=0;i<4;i++)
            {
                result=(result*(k%10))%10;
            }
        }
        for(i=0;i<k%4;i++)
        {
            result=(result*(k%10))%10;
        }
        printf("%d\n",result);
    }
}

转载地址:http://yttpi.baihongyu.com/

你可能感兴趣的文章
openstack虚拟机创建流程
查看>>
Android中AsyncTask的简单用法
查看>>
带WiringPi库的交叉笔译如何处理二之软链接概念
查看>>
Java8 HashMap集合解析
查看>>
fastcgi_param 详解
查看>>
poj 1976 A Mini Locomotive (dp 二维01背包)
查看>>
MODULE_DEVICE_TABLE的理解
查看>>
db db2_monitorTool IBM Rational Performace Tester
查看>>
postgresql监控工具pgstatspack的安装及使用
查看>>
【JAVA数据结构】双向链表
查看>>
【JAVA数据结构】先进先出队列
查看>>
Objective-C 基础入门(一)
查看>>
Flutter Boost的router管理
查看>>
iOS开发支付集成之微信支付
查看>>
C++模板
查看>>
【C#】如何实现一个迭代器
查看>>
【C#】利用Conditional属性完成编译忽略
查看>>
DirectX11 光照演示示例Demo
查看>>
VUe+webpack构建单页router应用(一)
查看>>
Node.js-模块和包
查看>>