[agc019f]Yes or No

本文探讨了一道数形结合的问题,通过将问题转化为图形路径问题,提出了一种简单直观的解决策略。文章详细分析了如何利用组合数学的方法来计算最优策略下的期望正确答案数量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言

一道数形结合的题目。
发现本质则十分简单(考虑分数相加则麻烦无比)。

题意

n+m个询问,有n个询问的答案是Yes,其余m个是No。
你依次回答这些询问,每个询问给出Yes或No,给出后告诉你答对了没有。
求最优策略下你期望答对的询问个数。

解法

不妨令n>=m。
最优策略,选择剩余多的,一样多乱猜一个。
然后画一条y=x的直线。
你假设从一个(i,i)走到(0,0)中途不到对角线。
那么显然你会一直猜同一个,一定会答对i个。
发现从(n,m)到(0,0)无论中途多曲折,经过对角线多少次,我们一个部分一个部分分开,都会答对对应次。
因此无论如何都会答对n次。
如果走到对角线上,我们会乱猜,只有1/2几率对。
因此对于对角线上每一个点统计经过它的方案数即可。
是不是很简单呢?

#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=500000+10,mo=998244353;
int fac[maxn*2],inv[maxn*2];
int i,j,k,l,t,n,m,ans;
int qsm(int x,int y){
    if (!y) return 1;
    int t=qsm(x,y/2);
    t=(ll)t*t%mo;
    if (y%2) t=(ll)t*x%mo;
    return t;
}
int C(int n,int m){
    if (n<m||m<0) return 0;
    return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int main(){
    scanf("%d%d",&n,&m);
    if (n<m) swap(n,m);
    fac[0]=1;
    fo(i,1,n*2) fac[i]=(ll)fac[i-1]*i%mo;
    inv[n*2]=qsm(fac[n*2],mo-2);
    fd(i,n*2-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
    fo(i,1,m)
        (ans+=(ll)C(2*i,i)*C(n+m-2*i,n-i)%mo)%=mo;
    ans=(ll)ans*qsm(2*C(n+m,n)%mo,mo-2)%mo;
    (ans+=n)%=mo;
    (ans+=mo)%=mo;
    printf("%d\n",ans);
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- Copyright (c) 2016-2020, The Linux Foundation. All rights reserved Not a Contribution. --> <!-- Copyright (C) 2015 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Changes from Qualcomm Innovation Center are provided under the following license: Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> <audioPolicyConfiguration version="7.0" xmlns:xi="http://www.w3.org/2001/XInclude"> <!-- version section contains a “version” tag in the form “major.minor” e.g version=”1.0” --> <!-- Global configuration Decalaration --> <globalConfiguration speaker_drc_enabled="true" call_screen_mode_supported="true"/> <!-- Modules section: There is one section per audio HW module present on the platform. Each module section will contains two mandatory tags for audio HAL “halVersion” and “name”. The module names are the same as in current .conf file: “primary”, “A2DP”, “remote_submix”, “USB” Each module will contain the following sections: “devicePorts”: a list of device descriptors for all input and output devices accessible via this module. This contains both permanently attached devices and removable devices. “mixPorts”: listing all output and input streams exposed by the audio HAL “routes”: list of possible connections between input and output devices or between stream and devices. "route": is defined by an attribute: -"type": <mux|mix> means all sources are mutual exclusive (mux) or can be mixed (mix) -"sink": the sink involved in this route -"sources": all the sources than can be connected to the sink via vis route “attachedDevices”: permanently attached devices. The attachedDevices section is a list of devices names. The names correspond to device names defined in <devicePorts> section. “defaultOutputDevice”: device to be used by default when no policy rule applies --> <modules> <!-- Primary Audio HAL is now hosted in audio_module_config_primary --> <!-- A2DP Audio HAL --> <!-- #ifndef OPLUS_BUG_STABILITY dongchuancheng@MULTIMEDIA.AUDIOSERVER.FRAMEWORK, 2022/09/29, disalbe unused a2dp module for qcom split bluetooth arch. <module name="a2dp" halVersion="2.0"> <mixPorts> <mixPort name="a2dp input" role="sink"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="44100 48000" channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/> </mixPort> </mixPorts> <devicePorts> <devicePort tagName="BT A2DP In" type="AUDIO_DEVICE_IN_BLUETOOTH_A2DP" role="source"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="44100 48000" channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/> </devicePort> </devicePorts> <routes> <route type="mix" sink="a2dp input" sources="BT A2DP In"/> </routes> </module> #endif OPLUS_BUG_STABILITY --> <!-- #ifndef OPLUS_FEATURE_BTAUDIO_LHDC //Yuepeifeng@TECH.CONN.BT.A2DP.36081 2020/03/29 for support LHDC codec--> <module name="bluetooth_qti" halVersion="2.0"> <mixPorts> <mixPort name="a2dp_lhdc output" role="source" flags="AUDIO_OUTPUT_FLAG_SPATIALIZER"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_OUT_STEREO AUDIO_CHANNEL_OUT_MONO"/> <profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_OUT_STEREO AUDIO_CHANNEL_OUT_MONO"/> </mixPort> <!-- #ifndef OPLUS_FEATURE_BTAUDIO_AID //fred.li@MULTIMEDIA.AUDIOSERVER.POLICY.1723426 2021/06/22 add for Hearing AIDs Audio Ports--> <mixPort name="hearing aid output" role="source"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="24000 16000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/> </mixPort> <!--endif OPLUS_FEATURE_BTAUDIO_AID--> </mixPorts> <devicePorts> <!-- A2DP Audio Ports --> <devicePort tagName="BT A2DP Out" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP" role="sink" encodedFormats="AUDIO_FORMAT_LHDC AUDIO_FORMAT_LHDC_LL"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_OUT_STEREO AUDIO_CHANNEL_OUT_MONO"/> <profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_OUT_STEREO AUDIO_CHANNEL_OUT_MONO"/> </devicePort> <devicePort tagName="BT A2DP Headphones" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES" role="sink" encodedFormats="AUDIO_FORMAT_LHDC AUDIO_FORMAT_LHDC_LL"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_OUT_STEREO AUDIO_CHANNEL_OUT_MONO"/> <profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_OUT_STEREO AUDIO_CHANNEL_OUT_MONO"/> </devicePort> <devicePort tagName="BT A2DP Speaker" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER" role="sink" encodedFormats="AUDIO_FORMAT_LHDC AUDIO_FORMAT_LHDC_LL"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_OUT_STEREO AUDIO_CHANNEL_OUT_MONO"/> <profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_OUT_STEREO AUDIO_CHANNEL_OUT_MONO"/> </devicePort> <!-- #ifndef OPLUS_FEATURE_BTAUDIO_AID //fred.li@MULTIMEDIA.AUDIOSERVER.POLICY.1723426 2021/06/22 add for Hearing AIDs Audio Ports--> <devicePort tagName="BT Hearing Aid Out" type="AUDIO_DEVICE_OUT_HEARING_AID" role="sink"/> <!--endif OPLUS_FEATURE_BTAUDIO_AID--> </devicePorts> <routes> <route type="mix" sink="BT A2DP Out" sources="a2dp_lhdc output"/> <route type="mix" sink="BT A2DP Headphones" sources="a2dp_lhdc output"/> <route type="mix" sink="BT A2DP Speaker" sources="a2dp_lhdc output"/> <!-- #ifndef OPLUS_FEATURE_BTAUDIO_AID fred.li@MULTIMEDIA.AUDIOSERVER.POLICY.1723426 2021/06/22 add for Hearing AIDs Audio Ports--> <route type="mix" sink="BT Hearing Aid Out" sources="hearing aid output"/> <!--endif /* OPLUS_FEATURE_BTAUDIO_AID */ --> </routes> </module> <!--endif OPLUS_FEATURE_BTAUDIO_LHDC--> <!-- Usb Audio HAL --> <module name="usb" halVersion="2.0"> <mixPorts> <mixPort name="usb_accessory output" role="source"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="44100" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/> </mixPort> </mixPorts> <devicePorts> <devicePort tagName="USB Host Out" type="AUDIO_DEVICE_OUT_USB_ACCESSORY" role="sink"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="44100" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/> </devicePort> </devicePorts> <routes> <route type="mix" sink="USB Host Out" sources="usb_accessory output"/> </routes> </module> <!-- #ifdef OPLUS_FEATURE_BTAUDIO_BINAURAL_RECORD --> <module name="binaural_record" halVersion="2.0"> <mixPorts> <mixPort name="Bluetooth record" role="sink"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/> <profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/> </mixPort> </mixPorts> <devicePorts> <devicePort tagName="BT Record in" type="AUDIO_DEVICE_IN_PROXY" role="source" address=""> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/> <profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED" samplingRates="44100 48000 96000" channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/> </devicePort> </devicePorts> <routes> <route type="mix" sink="Bluetooth record" sources="BT Record in"/> </routes> </module> <!-- #endif OPLUS_FEATURE_BTAUDIO_BINAURAL_RECORD --> <!-- #ifdef OPLUS_FEATURE_VIRTUAL_AUDIO --> <!-- ZhangHui@MULTIMEDIA.AUDIOSERVER.BASE, 2021/10/11, Add for virtual audio --> <xi:include href="/odm/etc/virtual_audio_policy_configuration.xml"> <xi:fallback></xi:fallback> </xi:include> <!-- #endif OPLUS_FEATURE_VIRTUAL_AUDIO --> <!-- Remote Submix Audio HAL --> <xi:include href="/vendor/etc/r_submix_audio_policy_configuration.xml"/> <!-- Bluetooth Audio HAL for hearing aid --> <!-- #ifndef OPLUS_BUG_STABILITY dongchuancheng@MULTIMEDIA.AUDIOSERVER.FRAMEWORK, 2022/09/20, disable unused module <xi:include href="/vendor/etc/bluetooth_qti_hearing_aid_audio_policy_configuration.xml"/> #endif /* OPLUS_BUG_STABILITY */ --> </modules> <!-- End of Modules section --> <!-- Volume section --> <!-- #ifndef OPLUS_BUG_STABILITY YeWenliang@MULTIMEDIA.AUDIODRIVER.HAL 2022/09/29 <xi:include href="/vendor/etc/audio_policy_volumes.xml"/> <xi:include href="/vendor/etc/default_volume_tables.xml"/> #else /* OPLUS_BUG_STABILITY */--> <xi:include href="audio_policy_volumes.xml"/> <xi:include href="default_volume_tables.xml"/> <!-- #endif /* OPLUS_BUG_STABILITY */ --> <!-- End of Volume section --> </audioPolicyConfiguration> 以上文件路径:/odm/etc/audio/audio_policy_configuration.xml 一加13 Coloros15,安卓版本15,修改该文件,绕过安卓音频SRC实现系统全局自适应采样率(Dynamic sampling rates)、自适应位深(Bit_perfect)(保持音频文件原始位深,16bit文件不升级位深)、禁用升频和重采样,关闭所有音频音效(effect)以及影响音频质量无损输出的一切音频处理,最大程度上抑制并降低音频抖动(jitter)(最大化优化时钟管理和同步)、最大程度降低音频失真和噪声以及电源纹波和噪声,以输出输入最干净无污染最高质量的HIFI无损原始音频信号直出,输出修改过的完整文件
最新发布
08-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值