码迷,mamicode.com
首页 > 其他好文 > 详细

NYOJ 88 汉诺塔(一)

时间:2015-07-03 21:58:49      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

#include<stdio.h>
const int max =1000000;
long long kuaimi(int n)
{
  long long temp=1;
  long long a=2;
  while(n>0)
  {
    if(n&1)
      temp=((temp*a)%max);
    a=((a*a)%max);
    n>>=1;
  }
  return temp;
}
int main()
{
  int num;
  scanf("%d\n",&num);
  while(num--)
  {
    int m;
    scanf("%d",&m);
    printf("%d\n",kuaimi(m)-1);
  }
}

NYOJ 88 汉诺塔(一)

标签:

原文地址:http://www.cnblogs.com/mycapple-zgs-111411/p/4619725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!