hdu1097

#include <stdio.h>

int calc(int a, int b)
{
if(a==0 || a==1 || a==5 || a==6) return a;
if(a==2)
{
if(b%4==1) return 2;
if(b%4==2) return 4;
if(b%4==3) return 8;
if(b%4==0) return 6;
}
if(a==3)
{
if(b%4==1) return 3;
if(b%4==2) return 9;
if(b%4==3) return 7;
if(b%4==0) return 1;
}
if(a==4)
{
if(b%2==1) return 4;
if(b%2==0) return 6;
}
if(a==7)
{
if(b%4==1) return 7;
if(b%4==2) return 9;
if(b%4==3) return 3;
if(b%4==0) return 1;
}
if(a==8)
{
if(b%4==1) return 8;
if(b%4==2) return 4;
if(b%4==3) return 2;
if(b%4==0) return 6;
}
if(a==9)
{
if(b%2==1) return 9;
if(b%2==0) return 1;
}
}

int main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF)
{
printf("%d\n",calc(a%10,b));
}
return 0;
}

时间: 2024-12-17 02:22:02

hdu1097的相关文章

HDU1097 A hard puzzle

A hard puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 29415    Accepted Submission(s): 10581 Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a a

(HDU)1097 --A hard puzzle(难题)

题目链接:http://vjudge.net/problem/HDU-1097 这题和前面出现的一道N的N次幂的原理是一样的,不明白的可以去看那题: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 6 int main() 7 { 8 int a,b,ans[4]; 9 while(~scanf("%d %d",&a