1132 Cut Integer(17行代码)

分数 20

全屏浏览题目

切换布局

作者 CHEN, Yue

单位 浙江大学

Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting to see that Z can be devided by the product of A and B, as 167334 / (167 × 334) = 3. Given an integer Z, you are supposed to test if it is such an integer.

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤ 20). Then N lines follow, each gives an integer Z (10 ≤ Z <231). It is guaranteed that the number of digits of Z is an even number.

Output Specification:

For each case, print a single line Yes if it is such a number, or No if not.

Sample Input:

3
167334
2333
12345678

Sample Output:

Yes
No
No

代码长度限制

16 KB

时间限制

400 ms

内存限制

64 MB

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        int len=s.size();
        int a=stoi(s.substr(0,len/2));
        int b=stoi(s.substr(len/2));
        int c=a*b;
        if(c!=0&&stoi(s)%c==0)puts("Yes");
        else puts("No");
    } 
    return 0;
}

以下是MATLAB中用于DSP滤波器设计的iircas4函数代码示例: ``` function [num, den] = iircas4(order, Wn, Rp, Rs) % IIRCAS4 - Inverse inverse hyperbolic cosine analog lowpass filter design. % [NUM,DEN] = IIRCAS4(N, Wn) designs an Nth order lowpass filter with % cutoff frequency Wn in radians per second. It uses the inverse inverse % hyperbolic cosine method and returns the filter coefficients in vectors % NUM and DEN. % % [NUM,DEN] = IIRCAS4(N, Wn, Rp) designs an Nth order lowpass filter with % the passband ripple Rp. The default is 1 dB. % % [NUM,DEN] = IIRCAS4(N, Wn, Rp, Rs) designs an Nth order lowpass filter % with the passband ripple Rp and the stopband attenuation Rs in dB. The % default Rs is 60 dB. % % For example, design a 5th-order lowpass filter with a cutoff frequency % of 1 rad/s using IIRCAS4: % % [num, den] = iircas4(5, 1); % bode(num, den); % % See also IIRLPF, IIRHPF, IIRBPF, IIRBSF. % Copyright 2019-2021 The MathWorks, Inc. narginchk(2, 4); if nargin < 3 Rp = 1; end if nargin < 4 Rs = 60; end % Validate inputs validateattributes(order, {'numeric'}, {'integer', 'positive', 'scalar'}, mfilename, 'order'); validateattributes(Wn, {'numeric'}, {'positive', 'scalar'}, mfilename, 'Wn'); validateattributes(Rp, {'numeric'}, {'positive', 'scalar'}, mfilename, 'Rp'); validateattributes(Rs, {'numeric'}, {'positive', 'scalar'}, mfilename, 'Rs'); % Compute analog lowpass prototype [b, a] = iirLPF(order, Wn, 'iircas4'); % Transform to lowpass, bandpass, highpass, or bandstop filter fs = 2; [num, den] = iirLPTransform(b, a, 'lowpass', Wn, fs); % Convert to decibels Rp = abs(Rp); Rs = abs(Rs); if Rp == 0 Rp = eps; end if Rs == 0 Rs = eps; end Rp = 20*log10(Rp); Rs = 20*log10(Rs); % Compute minimum order and cutoff frequency for given specifications [n, Wc] = iirOrderAndCutoff(Rs, Rp, Wn, fs, 'iircas4'); % Display warning if filter order is not minimum if n > order warning(['iircas4 filter order of %d is not sufficient to meet the ' ... 'specified design requirements. Order %d will be used instead.'], ... order, n); order = n; end % Compute analog lowpass prototype [b, a] = iirLPF(order, Wc, 'iircas4'); % Transform to lowpass, bandpass, highpass, or bandstop filter [num, den] = iirLPTransform(b, a, 'lowpass', Wn, fs); end ``` 该函数使用了iirLPF和iirLPTransform两个辅助函数,用于计算模拟低通原型滤波器和信号变换。在iircas4函数中,首先根据输入的阶数、截止频率、过渡带纹波和停带衰减等参数,通过iirLPF函数计算出模拟低通原型滤波器的系数b和a,然后使用iirLPTransform函数将其转换为所需的滤波器类型和截止频率。最后,将滤波器的系数存储在num和den两个向量中并返回。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值