杭电acm1061
2015-10-04 14:31
411 查看
这最后一个数只是最后个位数反复相乘的结果,而这结果只在0与9之间,我们只要计算出它的循环
长度即可。
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
while (n--)
{
int m;
cin>>m;
int a[10][5]={
{0,0,0,0,0},
{1,1,1,1,1},
{6,2,4,8,6},
{1,3,9,7,1},
{6,4,6,4,6},
{5,5,5,5,5},
{6,6,6,6,6},
{1,7,9,3,1},
{6,8,4,2,6},
{1,9,1,9,1}};
cout<<a[m%10][m%4]<<endl;
}
return 0;
}
长度即可。
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
while (n--)
{
int m;
cin>>m;
int a[10][5]={
{0,0,0,0,0},
{1,1,1,1,1},
{6,2,4,8,6},
{1,3,9,7,1},
{6,4,6,4,6},
{5,5,5,5,5},
{6,6,6,6,6},
{1,7,9,3,1},
{6,8,4,2,6},
{1,9,1,9,1}};
cout<<a[m%10][m%4]<<endl;
}
return 0;
}
相关文章推荐
- 登录失败:禁用的当前账户——window共享的傻X问题
- linux 惊群问题 http://blog.csdn.net/liujiyong7/article/details/43346829
- tomcat的配置
- 上传图片问题
- vsftp关于权限的条目配置
- 【兼容】浏览器兼容那些事
- 单词数
- The Stern-Brocot Number System(排序二进制)
- [codevs1380]没有上司的舞会
- #323 (Div. 2) B
- 实例分析Try {} Catch{} 作用
- select,poll,epoll实现分析—结合内核源代码 http://blog.csdn.net/vividonly/article/details/7539342
- 文章标题
- 萌妹子Python入门指北(一)
- Cocos2dx 3.0开发环境的搭建--Eclipse建立在Android工程
- 105. Construct Binary Tree from Preorder and Inorder Traversal (Tree; DFS)
- Add Binary | leetcode 67 【Java解题报告】
- GOF 23 设计模式之 解释器模式(Interpreter)与访问者模式(Visitor)
- 不懂技术不要对懂技术的人说这很容易实现
- ArrayList VS Vector VS LinkedList