3325. Kick_Start

题目连接

3325. Kick_Start

#include<bits/stdc++.h> 
using namespace std;
const int N=100000+10;
int main()
{
    int n;
    cin>>n;
    for(int j=1;j<=n;j++)
    {

    string s;
     cin>>s;
     int i=0;
     int len=s.length(); 
     int cnt=0,sum=0;
     while(i<=len-4)
    {
        if(s[i]=='K'&&s[i+1]=='I'&&s[i+2]=='C'&&s[i+3]=='K')cnt++;
        else if(s[i]=='S'&&s[i+1]=='T'&&s[i+2]=='A'&&s[i+3]=='R'&&s[i+4]=='T'&&i<=len-5)sum+=cnt;
     i++;   
    }cout<<"Case #"<<j<<":";
    cout<<sum<<endl;    
    }
    return 0;
}

作者:ajaoana
链接:https://www.acwing.com/activity/content/code/content/8820461/
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

2158 private boolean trySetEnabledFunctions(long usbFunctions, boolean forceRestart) { 2159 String functions = null; 2160 //#ifdef OPLUS_FEATURE_STORAGE_USB 2161 //Xuefeng.Peng@ANDROID.STORAGE.0, 2020/07/07, Add for USB tethering switch cannot be turned off 2162 usbFunctions = getOplusUsbDeviceFeature().usbTetheringSwitchOffFunctions(usbFunctions, mCurrentFunctionsStr); 2163 //#endif/*OPLUS_FEATURE_STORAGE_USB*/ 2164 if (usbFunctions != UsbManager.FUNCTION_NONE) { 2165 functions = UsbManager.usbFunctionsToString(usbFunctions); 2166 } 2167 mCurrentFunctions = usbFunctions; 2168 if (functions == null || applyAdbFunction(functions) 2169 .equals(UsbManager.USB_FUNCTION_NONE)) { 2170 //#ifdef OPLUS_FEATURE_STORAGE_USB 2171 //shubin@ANDROID.STORAGE.0, 2021/10/27, Add for remove mtp/ptp when set charging only 2172 String newFunction = functions; 2173 //#endif/*OPLUS_FEATURE_STORAGE_USB*/ 2174 //#ifdef QCOM_COMMON_BUG 2175 functions = getSystemProperty(getPersistProp(true), 2176 UsbManager.USB_FUNCTION_NONE); 2177 //#endif /* QCOM_COMMON_BUG */ 2178 //#ifdef OPLUS_FEATURE_STORAGE_USB 2179 //shubin@ANDROID.STORAGE.0, 2021/10/27, Add for remove mtp/ptp when set charging only 2180 if (newFunction == null) { 2181 if(containsFunction(functions, UsbManager.USB_FUNCTION_MTP)) 2182 functions = removeFunction(functions, UsbManager.USB_FUNCTION_MTP); 2183 if(containsFunction(functions, UsbManager.USB_FUNCTION_PTP)) 2184 functions = removeFunction(functions, UsbManager.USB_FUNCTION_PTP); 2185 if(containsFunction(functions, UsbManager.USB_FUNCTION_RNDIS)) 2186 functions = removeFunction(functions, UsbManager.USB_FUNCTION_RNDIS); 2187 } 2188 //#endif/*OPLUS_FEATURE_STORAGE_USB*/ 2189 //#ifdef QCOM_COMMON_BUG 2190 if (functions.equals(UsbManager.USB_FUNCTION_NONE)) 2191 //#endif /* QCOM_COMMON_BUG */ 2192 functions = UsbManager.usbFunctionsToString(getChargingFunctions()); 2193 } 2194 functions = applyAdbFunction(functions); 2195 2196 //#ifdef OPLUS_FEATURE_STORAGE_USB 2197 //Xuefeng.Peng@ANDROID.STORAGE.0, 2019/06/11, Add for eculid 2198 boolean isTelecomRequire = getOplusUsbDeviceFeature().isTelecomRequirement(functions); 2199 if (isTelecomRequire) { 2200 functions = "rndis,serial_cdev,diag,adb"; 2201 forceRestart = true; 2202 } 2203 //#endif/*OPLUS_FEATURE_STORAGE_USB*/ 2204 2205 String oemFunctions = applyOemOverrideFunction(functions); 2206 2207 if (!isNormalBoot() && !mCurrentFunctionsStr.equals(functions)) { 2208 setSystemProperty(getPersistProp(true), functions); 2209 }else if (isNormalBoot() && functions.equals("midi")) { 2210 forceRestart = true; 2211 } 2212 2213 //#ifdef OPLUS_FEATURE_STORAGE_USB 2214 //Xuefeng.Peng@ANDROID.STORAGE.1279692, 2018/02/13, Add for bootmode==reboot && sys.usb.config=rndis,when usb plug out, rndis can not close 2215 OplusUsbDeviceFunctionInfo info = new OplusUsbDeviceFunctionInfo( 2216 functions, oemFunctions, mCurrentFunctionsStr, 2217 mCurrentFunctionsApplied, forceRestart, mCurrentOemFunctions); 2218 getOplusUsbDeviceFeature().printFunctionsForDebug(info); 2219 //#endif /*OPLUS_FEATURE_STORAGE_USB*/ 2220 if ((!functions.equals(oemFunctions) 2221 && !mCurrentOemFunctions.equals(oemFunctions)) 2222 || !mCurrentFunctionsStr.equals(functions) 2223 || !mCurrentFunctionsApplied 2224 || forceRestart) { 2225 mCurrentFunctionsStr = functions; 2226 mCurrentOemFunctions = oemFunctions; 2227 mCurrentFunctionsApplied = false; 2228 2229 /** 2230 * Kick the USB stack to close existing connections. 2231 */ 2232 setUsbConfig(UsbManager.USB_FUNCTION_NONE); 2233 2234 if (!waitForState(UsbManager.USB_FUNCTION_NONE)) { 2235 Slog.e(TAG, "Failed to kick USB config"); 2236 return false; 2237 } 2238 2239 /** 2240 * Set the new USB configuration. 2241 */ 2242 setUsbConfig(oemFunctions); 2243 2244 if (mBootCompleted 2245 && (containsFunction(functions, UsbManager.USB_FUNCTION_MTP) 2246 || containsFunction(functions, UsbManager.USB_FUNCTION_PTP))) { 2247 /** 2248 * Start up dependent services. 2249 */ 2250 updateUsbStateBroadcastIfNeeded(getAppliedFunctions(mCurrentFunctions)); 2251 } 2252 2253 if (!waitForState(oemFunctions)) { 2254 Slog.e(TAG, "Failed to switch USB config to " + functions); 2255 return false; 2256 } 2257 2258 mCurrentFunctionsApplied = true; 2259 } 2260 return true; 2261 }
07-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值