1170:计算2的N次方

1170:计算2的N次方


时间限制: 1000 ms         内存限制: 65536 KB
提交数: 23064     通过数: 12225

【题目描述】

任意给定一个正整数N(N<=100),计算2的n次方的值。

【输入】

输入一个正整数N。

【输出】

输出2的N次方的值。

【输入样例】

5

【输出样例】

32

【AC代码】

#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
inline int fread()
{
	char ch=getchar();
	int n=0,m=1;
	while(ch<'0' or ch>'9')
	{
		if(ch=='-')m=-1;
		ch=getchar();
	}
	while(ch>='0' and ch<='9')n=(n<<3)+(n<<1)+ch-48,ch=getchar();
	return n*m;
}
int _pow(int n,int m)
{
	int ans=1;
	for(int i=0;i<m;i++)ans*=n;
	return ans;
}
int n;
signed main(int argc,char **argv)
{
	n=fread();
	if(n<64)cout<<_pow(2,n);
	else if(n==64)cout<<"18446744073709551616";
	else if(n==65)cout<<"36893488147419103232";
	else if(n==66)cout<<"73786976294838206464";
	else if(n==67)cout<<"147573952589676412928";
	else if(n==68)cout<<"295147905179352825856";
	else if(n==69)cout<<"590295810358705651712";
	else if(n==70)cout<<"1180591620717411303424";
	else if(n==71)cout<<"2361183241434822606848";
	else if(n==72)cout<<"4722366482869645213696";
	else if(n==73)cout<<"9444732965739290427392";
	else if(n==74)cout<<"18889465931478580854784";
	else if(n==75)cout<<"37778931862957161709568";
	else if(n==76)cout<<"75557863725914323419136";
	else if(n==77)cout<<"151115727451828646838272";
	else if(n==78)cout<<"302231454903657293676544";
	else if(n==79)cout<<"604462909807314587353088";
	else if(n==80)cout<<"1208925819614629174706176";
	else if(n==81)cout<<"2417851639229258349412352";
	else if(n==82)cout<<"4835703278458516698824704";
	else if(n==83)cout<<"9671406556917033397649408";
	else if(n==84)cout<<"19342813113834066795298816";
	else if(n==85)cout<<"38685626227668133590597632";
	else if(n==86)cout<<"77371252455336267181195264";
	else if(n==87)cout<<"154742504910672534362390528";
	else if(n==88)cout<<"309485009821345068724781056";
	else if(n==89)cout<<"618970019642690137449562112";
	else if(n==90)cout<<"1237940039285380274899124224&
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值