数论 --- 找规律

A hard puzzle#

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 28099    Accepted Submission(s): 10019


Problem Description
lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin.
this puzzle describes that: gave a and b,how to know the a^b's the last digit number.But everybody is too lazy to slove this problem,so they remit to you who is wise.
 

 

Input
There are mutiple test cases. Each test cases consists of two numbers a and b(0<a,b<=2^30)
 

 

Output
For each test case, you should output the a^b's last digit number.
 

 

Sample Input
7 66 8 800
 

 

Sample Output
9 6
 
【题目分析】
就是简单的找规律,规律很强。
 
复制代码
#include<cstdio>
int fun[10][4]=
{
    0,0,0,0,
    1,1,1,1,
    2,4,8,6,
    3,9,7,1,
    4,6,4,6,
    5,5,5,5,
    6,6,6,6,
    7,9,3,1,
    8,4,2,6,
    9,1,9,1
};
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        printf("%d\n",fun[a%10][(b-1)%4]);
    }
    return 0;
}
复制代码

 

 

 

 

 

 

 

posted @   北岛知寒  阅读(149)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
点击右上角即可分享
微信分享提示
主题色彩