• Codeforces--630B--Moore's Law(快速幂)


    

    Moore's Law

    Time Limit: 500MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u

    Status

    Description

    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.

    Sample Input

    Input
    1000 1000000
    
    Output
    1011.060722383550382782399454922040
    

    Sample Output

    Hint

    Source


    n每秒钟变大1.000000011 倍,问m秒之后变为多大,很明显,快速幂
    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    #define P 1.000000011
    double p(double c,int t)
    {
    	double aa=1;
    	while(t)
    	{
    		if(t&1) aa*=c;
    		c*=c;
    		t=t>>1;
    	}
    	return aa;
    }
    int main()
    {
    	int n,m;
    	while(cin>>n>>m)
    	{
    		double ans=p(P,m);
    		printf("%.8f
    ",ans*n);
    	}
    	return 0;
    }

  • 相关阅读:
    前端编程规范记录
    搬砖工坑爹教程
    JS的模块化编程学习之旅
    后端开发遇到的问题
    git学习中遇到的疑难杂症
    微信小程序填坑之旅
    详解Redis中两种持久化机制RDB和AOF
    redis系列:RDB持久化与AOF持久化
    Java中判断字符串是否为数字
    @Aspect 注解使用详解
  • 原文地址:https://www.cnblogs.com/playboy307/p/5273418.html
Copyright © 2020-2023  润新知