已知采样频率(单位KHz)、量化位数、声道数及持续时间(单位分钟),求未压缩时的数据量(单位MB).
例如:
输入: 22.05 16 2 3 (空格分隔)
输出:15.1MB(保留小数点后一位)
- #include
-
- int main(){
- float freq,bit,path,time;
- scanf("%f %f %f %f",&freq,&bit,&path,&time);
- //cin>>freq>>bit>>path>>time;
- float memory=freq*1000*bit*path*time*60/8;
- memory/=1048576;
- printf("%.1fMB",memory);
- return 0;
- }
注:此题注意最后需要加【MB】字样,否则无法ac。
该字符序列中含有a,b,c,d5个字符,输入为各字符的出现概率,及需要编码的字符序列,输出为算术编码区间(保留小数点后10位)。
例如:
输入:
0.2 0.3 0.1 0.15 0.25(空格分隔)
aaabded (待编码字符序列)
输出:
0.0033640000
0.0033775000
- #include
- using namespace std;
- #include
- #include
-
- int main(){
- double a,b,c,d,e;
- cin>>a>>b>>c>>d>>e;
-
- char wait[100];
- scanf("%s",wait);
-
- double aa,bb,cc,dd,left=0,right=1;
- int len=strlen(wait);
-
- aa=a;
- bb=a+b;
- cc=a+b+c;
- dd=a+b+c+d;
-
- for(int i=0;i
- char t=wait[i];
- double gap=right-left;
- double myleft=left;
- if(t=='a'){
- right=gap*aa+myleft;
- }
- else if(t=='b'){
- left=gap*aa+myleft;
- right=gap*bb+myleft;
- }
- else if(t=='c'){
- left=gap*bb+myleft;
- right=gap*cc+myleft;
- }
- else if(t=='d'){
- left=gap*cc+myleft;
- right=gap*dd+myleft;
- }
- else{
- left=gap*dd+myleft;
- }
- }
- printf("%.10f\n%.10f",left,right);
- return 0;
- }
3:对采用算术编码的符号序列进行译码,输出原始的符号序列
对于由a,b,c,d,e 5个符号组成的符号序列,输入各符号的出现概率及其算术编码,输出译码后的符号,符号长度是10位。
例如:
输入:
0.2 0.3 0.1 0.15 0.25 (空格分隔)
0.0033713425
输出:
aaabdedcbe
- #include
- using namespace std;
- #include
- #include
- /*
- 0.2 0.3 0.1 0.15 0.25
- 0.0033713425
- */
-
- int main(){
- double a,b,c,d,e,result;
- cin>>a>>b>>c>>d>>e;
- cin>>result;
-
- double aa,bb,cc,dd,left=0,right=1;
- aa=a;
- bb=a+b;
- cc=a+b+c;
- dd=a+b+c+d;
-
- char ret[100];
- int cnt=0;
- while(1){
- double gap=right-left;
- double node1=left+gap*aa;
- double node2=left+gap*bb;
- double node3=left+gap*cc;
- double node4=left+gap*dd;
-
- if(cnt==10){//left==right
- break;
- }
-
- if(result>=left && result
- ret[cnt++]='a';
- right=node1;
- }
- else if(result>=node1 && result
- ret[cnt++]='b';
- left=node1;
- right=node2;
- }
- else if(result>=node2 && result
- ret[cnt++]='c';
- left=node2;
- right=node3;
- }
- else if(result>=node3 && result
- ret[cnt++]='d';
- left=node3;
- right=node4;
- }
- else{
- ret[cnt++]='e';
- left=node4;
- }
- }
-
- for(int i=0;i
- cout<
- }
- return 0;
- }
-
相关阅读:
云原生系列 【基于CCE Kubernetes编排实战】
Unity 2D 游戏学习笔记(6)
通过宏封装实现std::format编译期检查参数数量是否一致
《洛谷深入浅出进阶篇》P1995 程序自动分析——并查集,离散化
USB协议学习(二)设备枚举过程分析
前端下载超大文件的完整方案
总结:协程与线程
代码随想录算法训练营 day46|139.单词拆分
测试十大法则
遥感云大数据在灾害、水体与湿地领域及GPT模型应用
-
原文地址:https://blog.csdn.net/m0_65787507/article/details/133430177
-
最新文章
-
沪漂五周年了:我越来越迷茫了
Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
MySQL-Seconds_behind_master的精度误差
[MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
Agent OS :五种驯服不确定性的范式
PortSwigger SQL注入LAB11
数据库即时编译JIT
[Begin]AI Learn Data Day 0
深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU