设为首页 加入收藏

TOP

HDU 1097 A hard puzzle
2015-07-20 17:20:29 来源: 作者: 【 】 浏览:3
Tags:HDU 1097 hard puzzle

这道题其实挺简单的,因为只看最后一位,所以就讨论最后一位的情况就可以了。而最后一位显然是有周期性的。

#include
  
   
#include
   
     #include
    
      #include
     
       #include
      
        using namespace std; int main() { int a,b,mode[12]; while(scanf("%d%d",&a,&b)!=EOF) { memset(mode,0,sizeof(mode)); a=a%10;//这里要注意 mode[1]=a; int cnt=1,t=a; while(true) { t=t*a%10; if(t==a) break; cnt++; mode[cnt]=t; } mode[0]=mode[cnt]; printf("%d\n",mode[b%cnt]); } return 0; } 
      
     
    
   
  


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇NYOJ表达式求值 下一篇NOJ1017 乘积最大 动态规划DP

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Redis on AWS:Elast (2025-12-27 04:19:30)
·在 Spring Boot 项目 (2025-12-27 04:19:27)
·使用华为开发者空间 (2025-12-27 04:19:24)
·Getting Started wit (2025-12-27 03:49:24)
·Ubuntu 上最好用的中 (2025-12-27 03:49:20)