杭电ACM 1012 1013 1014

STC8H8K64U ADC采样实战:从蜂鸣器控制到电压测量(附完整代码) 本文以STC8H8K64U单片机为核心,通过两个实战案例详细讲解ADC采样的应用。首先介绍如何利用ADC采样值动态控制蜂鸣器响度,实现模拟PWM效果;其次深入探讨高精度外部电压测量的方法,包括硬件连接、两点校准技巧以及软件滤波,旨在帮助开发者从理论到实践全面掌握ADC功能。 阅读详情

1012 . u Calculate e

Problem Description
A simple mathematical formula for e is

where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.

Output
Output the approximations of e generated by the above formula for the values of n from 0 to 9. The beginning of your output should appear similar to that shown below.

http://acm.hdu.edu.cn/showproblem.php?pid=1012

题目大意:用题目中给的级数估计e的值,对n从0到9,输出e的近似值。

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {

    public static void main(String args[]){
        System.out.println("n e");
        System.out.println("- -----------");
        System.out.println("0 1");
        System.out.println("1 2");
        System.out.println("2 2.5");
        BigDecimal r[]=new BigDecimal[9];
        BigDecimal e[]=new BigDecimal[7];
        for(int i=1;i<10;i++){
            r[i-1]=new BigDecimal(i);
        }
        for(int i=1;i<9;i++){
            r[i]=r[i].multiply(r[i-1]);
        }
        for(int i=1;i<9;i++){
            r[i]=r[0].divide(r[i],11,RoundingMode.HALF_DOWN);
        }
        e[0]=r[2].add(new BigDecimal("2.5"));
        System.out.printf("%d %.9f\n",3,e[0].setScale(9, RoundingMode.HALF_DOWN).doubleValue());
        for(int i=1;i<7;i++){
            e[i]=e[i-1].add(r[i+2]);
            System.out.printf("%d %.9f\n",(i+3),e[i].setScale(9, RoundingMode.HALF_DOWN).doubleValue());

        }
    }
}

System.out.printf(“%d %.9f\n”,3,e[0].setScale(9,RoundingMode.HALF_DOWN).doubleValue());注意这里的%.9f使得小数点后一定会输出九位,setScale函数是BigDecimal设置精度的函数,这里9代表精确到小数点后九位,RoundingMode.HALF_DOWN代表四舍五入的进位模式。

1013 .Digital Roots

Problem Description
The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit.

For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39.

Input
The input file will contain a list of positive integers, one per line. The end of the input will be indicated by an integer value of zero.

Output
For each integer in the input, output its digital root on a separate line of the output.

http://acm.hdu.edu.cn/showproblem.php?pid=1013

题目大意:就是对一个数字,将它的每一位数字加起来得到一个新的数字,再对新的数字做同样的事情,最终会得到一个一位数。求这个一位数。

import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        String str;
        while(s.hasNext()){
            str=s.nextLine();
            if(str.charAt(0)=='0')
                break;
            BigInteger n=new BigInteger(str);
            BigInteger ten=new BigInteger("10");
            BigInteger r=n.mod(ten);
            while(true){
                while(!(n.multiply(ten)).equals(new BigInteger("0"))){
                    n=n.divide(ten);
                    r=(n.mod(ten)).add(r);
                }
                if(r.compareTo(ten)<0)
                    break;
                else{
                    n=r;
                    r=n.mod(ten);
                }
            }
            System.out.println(r.toString());
        }
    }
}

要注意这里的数字可能很长,别用int,可以用String来读取数字,我这里选取直接用大整数的方法解决问题。

1014 .Uniform Generator

Problem Description
Computer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the form

seed(x+1) = [seed(x) + STEP] % MOD

where ‘%’ is the modulus operator.

Such a function will generate pseudo-random numbers (seed) between 0 and MOD-1. One problem with functions of this form is that they will always generate the same pattern over and over. In order to minimize this effect, selecting the STEP and MOD values carefully can result in a uniform distribution of all values between (and including) 0 and MOD-1.

For example, if STEP = 3 and MOD = 5, the function will generate the series of pseudo-random numbers 0, 3, 1, 4, 2 in a repeating cycle. In this example, all of the numbers between and including 0 and MOD-1 will be generated every MOD iterations of the function. Note that by the nature of the function to generate the same seed(x+1) every time seed(x) occurs means that if a function will generate all the numbers between 0 and MOD-1, it will generate pseudo-random numbers uniformly with every MOD iterations.

If STEP = 15 and MOD = 20, the function generates the series 0, 15, 10, 5 (or any other repeating series if the initial seed is other than 0). This is a poor selection of STEP and MOD because no initial seed will generate all of the numbers from 0 and MOD-1.

Your program will determine if choices of STEP and MOD will generate a uniform distribution of pseudo-random numbers.

Input
Each line of input will contain a pair of integers for STEP and MOD in that order (1 <= STEP, MOD <= 100000).

Output
For each line of input, your program should print the STEP value right- justified in columns 1 through 10, the MOD value right-justified in columns 11 through 20 and either “Good Choice” or “Bad Choice” left-justified starting in column 25. The “Good Choice” message should be printed when the selection of STEP and MOD will generate all the numbers between and including 0 and MOD-1 when MOD numbers are generated. Otherwise, your program should print the message “Bad Choice”. After each output test set, your program should print exactly one blank line.

http://acm.hdu.edu.cn/showproblem.php?pid=1014

题目大意:就是求两个数字的最大公约数,如果为1就是Good Choice。

import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        while(s.hasNext()){
            int a=s.nextInt();
            int b=s.nextInt();
            if(gcd(a,b)==1){
                System.out.printf("%10d%10d    Good Choice",a,b);
                System.out.println();
            }
            else{
                System.out.printf("%10d%10d    Bad Choice",a,b);
                System.out.println();
            }
            System.out.println();
        }
    }

    private static int gcd(int a, int b) {
        // TODO Auto-generated method stub
        if(a<b){
            a=a^b;
            b=a^b;
            a=a^b;
        }
        if(b==0)
            return a;
        return gcd(b,a-b);
    }
}

注意输出格式System.out.printf(“%10d%10d Good Choice”,a,b);

基于瑞芯微RK3562 四核 ARM Cortex-A53 + 单核 ARM Cortex-M0——Linux应用开发手册 本文主要介绍TL3562-MiniEVM评估板的AMP(Asymmetric Multi-processing)开发案例,介绍基于Linux + RT-Thread(RTOS)、Baremetal的AMP案例的开发环境搭建。 阅读详情

相关推荐

知识的定义与分类体系详解 - 从零基础到专业理解

知识的定义与分类体系详解 - 从零基础到专业理解

engchina的专栏 4423

杭电1013(JAVA版)

Digital Roots Problem Description The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, t..

weixin_45743399的博客 209

迅投miniQMT量化交易之【网格交易】的实现(25)——写在最后

和大家一起分享如何使用miniQMT实现我们自己的网格交易系统。如果您对量化交易感兴趣,欢迎一起交流。

tzzqn2008的专栏 838

杭电oj(1008、1012、1013、1014、1017)题解

杭电oj(1008、1012、1013、1014、1017)题解。

欢迎大家一起讨论交流 1202

Qt OpenGL 3D 点云数据显示

在Qt中使用OpenGL显示3D点云数据是一个常见的需求,特别是在计算机视觉、机器人学和三维重建等领域。下面我将介绍一个基本的实现方案。

深之JohnChen的专栏 1243

ads设计Doherty功放(1)

Doherty功放的设计

qq_40995480的博客 2万+

杭电 OJ-ACM 1012 (u Calculate e)

ACM1012

m0_73891157的博客 590

把 300 亿参数的 Qwen3-30B-A3B 塞进 16GB 手机:MoE、mmap 与内存轮转的完整拆解

这篇文章详细拆解了如何在16GB内存手机上运行305亿参数的Qwen3-30B-A3B大模型。作者通过MoE(专家混合)架构、内存映射(mmap)和专用NPU内存(rpcmem)的巧妙结合实现了这一"不可能"的任务。 核心原理在于:MoE模型将庞大的前馈网络拆分为128个专家,每个词只激活8个专家,97%的权重处于闲置状态;通过mmap技术按需加载当前需要的专家权重;同时利用NPU专用内存高效计算关键部分。三个关键开关(GGML_HEXAGON_MOE_PAGING=1、--mmap、GGML_CPU_RE

q742971636的博客 198

杭电OJ记录--1012

1012–精确计算e 注意输出格式与题目一致 前三行直接输出 之后小数部分保留九位有效数字,不够则补0 ————AC代码———— #include <iostream> #include <iomanip> using namespace std; int main() { int n = 0, i = 1; double fm = 1.0; double *a = new double[10]; //存放 1/(i!),i从0到9共10项 a[0] = 1.

CherryTaylor的博客 332

【数据集】中国多属性建筑数据集CMAB

【数据集】中国多属性建筑数据集CMAB

WW、forever的博客 4530

LPDDR5 物理层一致性测试(连载・下):电平、过冲下冲与 Rx 接收眼图 Mask 掩模完整指标解读

本文系统梳理LPDDR5物理层一致性测试全流程,涵盖差分/单端电平、边沿斜率、交叉点电压、过冲下冲及CS/CA/DQ接收眼图掩模(Rx Mask)测试,详解各参数定义与工程实操要点。强调配置需与DRAM MR寄存器同步,突出差分≠合格、面积积分不可忽视、掩模失败优先排查参考电压与信号完整性等高频坑点,为硬件调试与SI工程师提供权威参考。

一只豌豆象的博客 80

杭电ACM 1013 Digital Roots

http://acm.hdu.edu.cn/showproblem.php?pid=1013 这道题是求一个正数的根(digital root),各个位数不断相加知道取得个数。 首先,我想到的是把int型的数变成char数组。用itoa()函数。 #include #include using namespace std; int main(){ int n,sum=0; char

GinSmile的博客 4619

1、掌握 Microsoft Dynamics 365 Business Central 开发全解析

本文全面解析了Microsoft Dynamics 365 Business Central的开发全流程,涵盖开发环境搭建、AL语言扩展开发、定制解决方案实现、高级开发技术、文件与报表处理、打印功能、调试与性能优化、API使用、Azure和Power Platform集成、DevOps实践以及生成式AI应用。同时探讨了开发工具技巧、常见问题解决、开发流程优化、团队协作要点及未来技术趋势,帮助开发者系统掌握Business Central开发核心技能,提升企业级应用开发效率与质量。

food6的博客 122

杭电ACM基础题目(1000 1001 1004 1005 1008 1012 1014)

1001、Sum Problem Code: 1、注意:输出格式的要求,因为题目要求空一行,所以需要cout<<endl<<endl; 2、计算从1-n的和并输出 #include<iostream> using namespace std; int main() { int n,sum; while (cin >> n) { ...

柠檬超级酸 1035

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

杭电acm题目分类 非常详细

按此做成就大神之路:   1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最近点对问题,用分治 1008 简单题 1009 贪心 1010 搜索题,剪枝很关键 1011 1012 简单题 1013 简单题(有个小陷阱) 1014 简单题 101

舒哥的blog 2万+

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

杭电ACM题目分类

原文地址:杭电ACM题目分类作者:zzu追梦人第一篇     1001 这个就不用说了吧 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最近点对问题,用分治 1008 简单题 1009 贪心 1010 搜索题,剪枝很关键 1011  1012 简单题 1013 简单题(有

591

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

杭电acm题目分类版本1

杭电acm题目分类版本1   2009-10-18 12:51:21|  分类: asdf转载 |  标签: |字号大中小 订阅 1002       简单的大数 1003       DP经典问题,最大连续子段和 1004       简单题 1005       找规律(循环点) 1006       感觉有点BT的题,我到现在还没过

时刻保持危机感&对知识的渴望 1098

杭电acm分类

转自:http://blog.sina.com.cn/s/blog_889dc07b0101c969.html 标签:  it 分类: Cplusplus程序设计 差不多大二的时候开始接触acm,主要是自己练着玩,自己也参加了学校的两次程序设计大赛.当时主要就是 在杭电的acm网址上练习,很惭愧,刷的题目很少,不过这个经历也

u011909633的专栏 905

有关杭电acm问题的分类

转载的!呵呵呵!!! 第一篇 1001 这个就不用说了吧 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最近点对问题,用分治 1008 简单题 1009 贪心 1010 搜索题,剪枝很关键 1011 1012 简单题 1013 简单题(有个小陷...

weixin_30367873的博客 130

杭电ACM题单整理

杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最近点对问题,用分治 1008 简单题 1009 贪心 1010 搜索题,剪枝很关键 1011 1012 简单题 1013 简单题

一苇以航 4866

杭电acm第2304题答案c语言,【转】杭电ACM试题分类

注:网上搜的第一篇1001 这个就不用说了吧1002 简单的大数1003 DP经典问题,最大连续子段和1004 简单题1005 找规律(循环点)1006 感觉有点BT的题,我到现在还没过1007 经典问题,最近点对问题,用分治1008 简单题1009 贪心1010 搜索题,剪枝很关键10111012 简单题1013 简单题(有个小陷阱)1014 简单题1015 可以看作搜索题吧1016 经典的搜索...

weixin_42299775的博客 455

杭电ACM题目类型整理

版权声明:(╯3╰) 转载请注明: http://blog.csdn.net/bat67 杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最近点对问题,用分治 1008 简单题 1009 贪

zhukunang1998的博客 2811

杭电ACM(HDUOJ)试题分类

杭电ACM试题分类  第一篇  1001 这个就不用说了吧                      1002 简单的大数                            1003 DP经典问题,最大连续子段和            1004 简单题                                1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还

小夏 的博客 2211

【转载】杭电acm分类

【很棒,感觉很有用,转过来马克   原网址http://blog.sina.com.cn/s/blog_889dc07b0101c969.html】 ———————————————————————————————————————————————————————————————————————— 差不多大二的时候开始接触acm,主要是自己练着玩,自己也参加了学校的两次程序设计大赛.当时主要就是

weiwanshu的专栏 898

杭电ACM试题分类,一步一个脚印!(转)

杭电ACM试题分类 注:网上搜的 第一篇 1001 这个就不用说了吧1002 简单的大数1003 DP经典问题,最大连续子段和1004 简单题1005 找规律(循环点)1006 感觉有点BT的题,我到现在还没过1007 经典问题,最近点对问题,用分治1008 简单题1009 贪心1010 搜索题,剪枝很关键10111012 简单题1013 简单题(有个小陷阱)1014 简单题...

weixin_30485291的博客 129

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1、2、3、4、5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails ...

weixin_30408675的博客 529
上一篇: 杭电ACM 1008 1009
下一篇: 杭电ACM 1017 1018 1019
JeCode
博客等级 码龄11年 7粉丝 13原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值