CodeForces 630B Moore's Law(摩尔定律,快速幂)

博客详细介绍了CodeForces中关于摩尔定律的问题630B,每秒晶体管数按1.000000011倍增长。给出初始晶体管数n和经过的秒数t,要求求解t秒后的晶体管数,答案要求相对误差不超过10^-6。博主分享了利用快速幂运算解决此问题的思路和AC代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://codeforces.com/problemset/problem/630/B

B. Moore's Law
time limit per test
0.5 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

The city administration of IT City decided to fix up a symbol of scientific and technical progress in the city's main square, namely an indicator board that shows the effect of Moore's law in real time.

Moore's law is the observation that the number of transistors in a dense integrated circuit doubles approximately every 24 months. The implication of Moore's law is that computer performance as function of time increases exponentially as well.

You are to prepare information that will change every second to display on the indicator board. Let's assume that every second the number of transistors increases exactly 1.000000011 times.

Input

The only line of the input contains a pair of integers n (1000 ≤ n ≤ 10 000) and t (0 ≤ t ≤ 2 000 000 000) — the number of transistors in the initial time and the number of seconds passed since the initial time.

Output

Output one number — the estimate of the number of transistors in a dence integrated circuit in t seconds since the initial time. The relative error of your answer should not be greater than 10 - 6.

Examples
input
1000 1000000
output
1011.060722383550382782399454922040


题意:

著名的摩尔定律(可以问小度),题目描述为,每一秒钟都会在原来的基础上,集成电路晶体管的增加 1.000000011 倍,

给定原来的数量 n ,问经过 t 秒后晶体管的数量。

思路:

快速幂运算。

AC CODE:

#include<stdio.h>
#include<cstring>
#include<algorithm>
#define AC main()
using namespace std;
const int MYDD = 1103;

double PowQuick(double a, int n) {//快速幂 a^n 
	double ans = 1;
	while(n > 0) {
		if(n & 1)	ans *= a;// n 为奇数 
		a = a*a;
		n >>= 1;// 除 2 
	}
	return ans;
}

int AC {
	int n, t;
	scanf("%d %d", &n, &t);
	printf("%.8lf\n", n * PowQuick(1.0*1.000000011, t));
	return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值