跳到正文

题解

题解:AT_arc054_b [ARC054B] ムーアの法則

Seraphiel约 2 分钟
原文
文章信息与版本

文章信息

发布
2025年4月12日
收录
2025年12月12日
更新
2026年11月13日
篇幅
约 2 分钟
获赞
8

版本

  1. v1当前

这里来一篇纯摩尔定律计算的题解。

思路

首先思考摩尔的指数。计算机速度每 1.51.5 年翻倍,所以我们先设当前速度为 v0v_0,则 nn 年后的速度为 v(n)=v0×2n/1.5v(n)=v_0\times2^{n/1.5}。

第二想如何计算时间。题面中提出由于现代计算机需要 PP 年,则 nn 年后的时间为 P2n/1.5\frac{P}{2^{n/1.5}}。

第三将 nn 年再加上刚刚计算出的时间得到总时间。

到这里开始第二部分的推导。

第一对于推导出来的总时间求导并找到边界点:f(n)=n+P×2−n/1.5f(n)=n+P\times2^{-n/1.5}。令导数为 00 后求导,解出 2−n/1.5=1.5P×log2⁡2^{-n/1.5}=\frac{1.5}{P\times \operatorname{log_2}}。提取出 log2⁡\operatorname{log_2},得到:n=1.5log2⁡×log⁡(P×log2⁡1.5)n=\frac{1.5}{\operatorname{log_2}}\times \operatorname{log}(\frac{P\times \operatorname{log_2}}{1.5})。

最后一步是判断情况。如果 P×log2⁡1.5≤1\frac{P\times \operatorname{log_2}}{1.5}\le1,简单分析可知 n≤0n\le0,根据题意直接输出 PP。否则利用公式计算总时间。

code

C++
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f  
using namespace std;
int main(){
    double n;
    cin>>n;
    double log2=log(2);
    double temp=(n*log2)/1.5;
    if(temp<=1.0){
        cout<<fixed<<setprecision(10)<<n<<'\n';
    }
	else{
        double t=(1.5/log2)*log(temp);
        cout<<fixed<<setprecision(10)<<t+n/pow(2,t/1.5)<<'\n';
    }
    return 0;
}