zoukankan      html  css  js  c++  java
  • 杭电1061

    此题是一道观察技巧题!先找规律,然后再做,如果直接来的话,肯定会超时的哈!
    对于然和一个输入的整数m,先判断它的尾数是几,然后须寻找规律,
    1)当尾数是 0,1,5,6的时候,无乱多少次方,其尾数都不变,及周期是1。
    2)当尾数是 4:(4,9) 周期是2;当尾数是9:(1,9) 周期也是2;

                               
    3)当尾数是2,3,7,8的时候,2:(2,4,8,6);周期是4;
                                 3:(3,9,7,1);
                                 7:(7,9,3,1);
                                 8:(8,4,2,6);

    哈哈!规律已经有了!剩下看你的了哈!                                   
               

    #include<iostream>
    using namespace std;
    int main()
    {
      int n,m,l;
      int a[10][4]={{0},{1},{6,2,4,8},{1,3,9,7},{6,4},{5},{6},{1,7,9,3},{6,8,4,2},{1,9}};
      cin>>n;
      while(n--)
      {
      cin>>m;
      l=m%10;
         if(l==0||l==1||l==5||l==6)
       printf("%d\n",a[l][0]);
      if(l==4||l==9)
       printf("%d\n",a[l][m%2]);
      if(l==2||l==3||l==7||l==8)
       printf("%d\n",a[l][m%4]);
      }
      return 0;
    }

  • 相关阅读:
    个税
    MC9S08中断机制
    各大公司面试笔试
    uc/OSII 任务切换
    Source Insight 使用
    充70送70
    兔年大年30
    pip更新后报No module named pip
    MsSql Md5
    iOS UIImage扩展方法(category):放大、旋转、合并UIImage、增加渐变层、添加阴影、调节透明度、保存到相册
  • 原文地址:https://www.cnblogs.com/xiohao/p/2754068.html
Copyright © 2011-2022 走看看