博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1051 - Rightmost Digit
阅读量:6985 次
发布时间:2019-06-27

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

找循环

1 #include 
2 #include
3 using namespace std; 4 int t,m,p,q; 5 long long n; 6 int c[15],ans; 7 int main() 8 { 9 scanf("%d",&t);10 while(t--)11 {12 scanf("%lld",&n);13 m=n%10;14 int cnt=0,i;15 c[++cnt]=m;16 p=(m*m)%10;17 while(p!=m)18 {19 c[++cnt]=p;20 p=(p*m)%10;21 }22 ans=(n-1)%cnt+1;23 printf("%d\n",c[ans]);24 }25 } 26 /*27 3 9 7 1 328 4 6 4 629 */

 

转载于:https://www.cnblogs.com/nicetomeetu/p/5471814.html

你可能感兴趣的文章
面试准备之内存管理
查看>>
Qt4问题集锦
查看>>
linux mount文件夹
查看>>
申请免费ssl证书
查看>>
架构漫谈(1):什么是架构
查看>>
Appium
查看>>
兄弟连初体验
查看>>
规范打log
查看>>
Redis 错误1067:进程意外终止,Redis不能启动,Redis启动不了
查看>>
Linux Redis 重启数据丢失解决方案,Linux重启后Redis数据丢失解决方
查看>>
ArcGIS API for javascript开发笔记(五)——GP服务调用之GP模型的发布及使用详解...
查看>>
C#读写xml文件应用
查看>>
关于磁盘,磁柱,磁头,扇区的概念
查看>>
Layer 父子页面之间的交互
查看>>
WPF
查看>>
IQ推理:红眼睛和蓝眼睛
查看>>
Python中lambda使用简易教程
查看>>
函数调用运算符"()"
查看>>
PHP数组传递给JavaScript以及json_encode的gbk中文乱码的解决
查看>>
<转>python version 2.7 required,which was not found in the registry
查看>>