CSU 1524: Tone Number of MIDI
来源:互联网 发布:数据中心数据备份系统 编辑:程序博客网 时间:2024/06/05 08:02
题目:
Description
Recently, we have made a little software called Query by Humming. One of the important thing is to transform the frequency of a sound to the tone number of MIDI. You can see the relations between them in the picture below:
t = 12.0 * log2(f/440) + 69.0
Generally, we can transform the frequency of a sound to the tone of MIDI using the formula below:
Here f is the frequency of the sound and t is the tone of MIDI.
Then the integer nearest to t is the tone number. That is, the tone number is an integer x such that |x - t| is minimum. You can assume there is only one integer is nearest to t in this problem.
Input
The first line contains the number of test cases T (0 < T ≤ 200).
For each test case, there is only one line containing a real number f (82 < f < 1047) with at most 5 decimal places, giving the frequency of a sound.
Output
For each test case, output the tone number transformed.
Sample Input
5440.0123463.45678840.003859.99700.5364
Sample Output
6970808177
只有一个地方需要注意,int()这个函数,如果参数是负数,那么算出来的就和高斯函数不一样了,所以69只能放括号里面,不能放最外面。
代码:
#include<iostream>#include<math.h>using namespace std;int main(){int t;cin >> t;double f;while (t--){cin >> f;cout << int(log2(f / 440) * 12 + 69.5) << endl;}return 0;}
- CSU 1524: Tone Number of MIDI
- CSU 1522: Extravagant number
- MIDI
- MIDI
- MIDI
- MIDI
- CSU 1519: Sum of Integers
- csu 1282 Sphenic Number 暴力 解题报告
- ProjectMIDI: an extensible set of small MIDI .NET programs
- Tone Mapping
- Tone Mapping
- Tone Mapping
- CSU 1034 The Composition of Letters
- CSU 1697 Surface Area of Cubes (思维)
- CSU
- CSU
- CSU
- CSU
- 部署LyncServer2013之一 前期准备
- Xcode7如何添加pch宏文件
- Lync Server 2013 的 Enterprise Edition 前端池部署中的服务器并置
- Spark加载外部配置文件
- 组策略应用之部署bginfo软件
- CSU 1524: Tone Number of MIDI
- LyncServer2013归档服务器部署之查看员工聊天记录
- ios pdf字节缓存本地
- 部署LyncServer2013归档服务器
- ASCII码排序 南阳理工ACM 题目4
- Lync 地址簿同步知识点
- 色彩深度、灰阶
- 程序员的生存技巧 —— 搜索技巧
- LayoutInflater.inflate源码详解