杭电1097题目:下面是我的编程,求指教,为什么老师说time limited
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/14 03:40:10
杭电1097题目:下面是我的编程,求指教,为什么老师说time limited
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
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
//
#include
int main()
{
int i, n, a, b;
while(scanf("%d%d", &a, &b) != EOF)
{
n = a % 10;
switch(n)
{
case 0:
case 1:
case 5:
case 6:
printf("%d", n); //尾数为0,1,5,6 时, a^b以后还是一样的
break;
case 2: //尾数为2
if(b % 4 == 0)printf("6");
else if(b % 4 == 1)printf("2");
else if(b % 4 == 2)printf("4");
else printf("8");
break;
case 3: //尾数为3
if(b % 4 == 0)printf("1");
else if(b % 4 == 1)printf("3");
else if(b % 4 == 2)printf("9");
else printf("7");
break;
case 4:
if(b % 2)printf("4");
else printf("6");
break;
case 7:
if(b % 4 == 0)printf("1");
else if(b % 4 == 1)printf("7");
else if(b % 4 == 2)printf("9");
else printf("3");
break;
case 8:
if(b % 4 == 0)printf("6");
else if(b % 4 == 1)printf("8");
else if(b % 4 == 2)printf("4");
else printf("2");
break;
case 9:
if(b % 2)printf("9");
else printf("1");
break;
}
printf("\n");
}
}
//祝学习进步,更上一层楼 *^_^* !
#include
int main()
{
int i, n, a, b;
while(scanf("%d%d", &a, &b) != EOF)
{
n = a % 10;
switch(n)
{
case 0:
case 1:
case 5:
case 6:
printf("%d", n); //尾数为0,1,5,6 时, a^b以后还是一样的
break;
case 2: //尾数为2
if(b % 4 == 0)printf("6");
else if(b % 4 == 1)printf("2");
else if(b % 4 == 2)printf("4");
else printf("8");
break;
case 3: //尾数为3
if(b % 4 == 0)printf("1");
else if(b % 4 == 1)printf("3");
else if(b % 4 == 2)printf("9");
else printf("7");
break;
case 4:
if(b % 2)printf("4");
else printf("6");
break;
case 7:
if(b % 4 == 0)printf("1");
else if(b % 4 == 1)printf("7");
else if(b % 4 == 2)printf("9");
else printf("3");
break;
case 8:
if(b % 4 == 0)printf("6");
else if(b % 4 == 1)printf("8");
else if(b % 4 == 2)printf("4");
else printf("2");
break;
case 9:
if(b % 2)printf("9");
else printf("1");
break;
}
printf("\n");
}
}
//祝学习进步,更上一层楼 *^_^* !
杭电1097题目:下面是我的编程,求指教,为什么老师说time limited
杭电acm 1005 我觉得很简单,不知道怎么出现stack_overflow,求大神指教.下面是代码.
为什么有限公司的翻译是 company limited 而不是limited company?
给片作文,题目《我的老师》,下面是要求
matlab编程问题 不知道为什么运行不了,求大神指教,目的是把所矩阵的符合条件的元素取出作为一个新矩阵
求老师解答:下面是小明的同学在电
求一篇作文,题目是我的老师
关于物理欧姆定律R=U/I 老师说,R与U和I不成比例,因为无论电压电流如何,电阻值是一定的,这个我明白.但有的题目上说
求编程,从键盘输入圆的半径,求该圆的周长和面积 下面是我做的,
老师要我们写一篇(我与老师)的作文,求大神指教、、
急求一篇作文,题目《我最熟悉的一位老师》,老师说选的人物要有个性,与众不同.
在书上看到一个题目,答案是D,不知道为什么,求高人指教: