前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【ZOJ2277】The Gate to Freedom

【ZOJ2277】The Gate to Freedom

作者头像
饶文津
发布2020-06-02 12:21:26
2480
发布2020-06-02 12:21:26
举报
文章被收录于专栏:饶文津的专栏饶文津的专栏

题意

题解

代码

代码语言:javascript
复制
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int n;
int main() {
	while(~scanf("%d",&n))
		printf("%d\n",(int)pow(10,n*log10(n)-(int)(n*log10(n))));
	return 0;
}

快速幂暴力

代码语言:javascript
复制
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define ll long long
using namespace std;
double pow(double a,int b){
	double ans=1;
	while(b){
		if(b&1){
			ans=ans*a;
		}
		a=a*a;
		while(a<0.01)a*=10;
		b>>=1;
	}
	return ans;
}
int main() {
 	int n;
	while(~scanf("%d",&n)){
		double t=n;
		while(t>=1)t/=10;
		double ans=pow(t,n);
		while(ans<1)ans*=10;
		
		printf("%d\n",(int)ans);
	}
	return 0;
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-02-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 题意
  • 题解
  • 代码
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档