「ABC221A」Seismic magnitude scales 题解

A - Seismic magnitude scales

Time Limit: \(2\; sec\) / Memory Limit: \(1024\; MB\)

Score : \(100\; points\)

Problem Statement|题目描述

  • The magnitude of an earthquake is a logarithmic scale of the energy released by the earthquake. It is known that each time the magnitude increases by \(1\), the amount of energy gets multiplied by approximately \(32\).

  • 地震的震级是地震释放能量的对数尺度。已知震级每增加 \(1\) ,能量就会变为原来的大约 \(32\) 倍。

  • Here, we assume that the amount of energy gets multiplied by exactly \(32\) each time the magnitude increases by \(1\). In this case, how many times is the amount of energy of a magnitude \(A\) earthquake as much as that of a magnitude \(B\) earthquake?

  • 在本题中,我们假设每次震级增加 \(1\) 时,能量正好乘以 \(32\) 。在这种情况下, \(A\) 地震的能量是 \(B\) 级地震能量的多少倍?

Constraints|数据范围

  • \(3\leq B\leq A\leq 9\)
  • \(A\) and \(B\) are integers.
  • \(3\leq B\leq A\leq 9\)
  • \(A\)\(B\) 均为整数。

Input|输入

  • Input is given from Standard Input in the following format:
    A B

  • 输入为以下格式的标准输入:
    A B

Output|输出

  • Print the answer as an integer.

  • 输出一个整数答案。

Sample Input 1 |样例输入 1

6 4

Sample Output 1 |样例输出 1

1024

  • \(6\) is \(2\) greater than \(4\), so a magnitude \(6\) earthquake has \(32\times 32=1024\) times as much energy as a magnitude \(4\) earthquake has.
  • \(6\) 级地震的能量是 \(4\)级地震的 \(32\times 32=1024\) 倍。

Sample Input 2 |样例输入 2

5 5

Sample Output 2 |样例输出 2

1

  • Earthquakes with the same magnitude have the same amount of energy.
  • 相同震级的地震具有相同的能量。

分析

作为一个谨慎的人,我终究还是开了\(long\;long\),又用了快速幂。

AC代码奉上

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll power(ll a,ll b){
	if(!b)return 1;
	ll ans=1;
	while(b){
		if(b&1)ans=ans*a;
		b>>=1;
		a*=a;
	}
	return ans;
}
int main(){
	freopen("magnitude.in","r",stdin);
	freopen("magnitude.out","w",stdout);
	int a,b;
	cin>>a>>b;
	cout<<power(32,a-b);
	return 0;
} 

$$-----CONTINUE-----$$

> next 「ABC221B」typo 题解

> catalogue 「ABC221」题解

posted @ 2021-10-04 16:48  AlienCollapsar  阅读(156)  评论(0编辑  收藏  举报
// 生成目录索引列表 // ref: http://www.cnblogs.com/wangqiguo/p/4355032.html // modified by: zzq