问题 H: Wanna go back home

题目描述
Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1≤i≤N), he will travel a positive distance in the following direction:

North if the i-th letter of S is N
West if the i-th letter of S is W
South if the i-th letter of S is S
East if the i-th letter of S is E
He has not decided each day’s travel distance. Determine whether it is possible to set each day’s travel distance so that he will be back at home at the end of Day N.

Constraints
1≤|S|≤1000
S consists of the letters N, W, S, E.
输入
The input is given from Standard Input in the following format:
S
输出
Print Yes if it is possible to set each day’s travel distance so that he will be back at home at the end of Day N. Otherwise, print No.
样例输入 Copy
SENW
样例输出 Copy
Yes
提示
If Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.

cin>>a;
z=a.size();
for(i=0;i<z;i++)
{
    if(a[i]=='N')
        b.n++;
    else if(a[i]=='S')
        b.s++;
    else if(a[i]=='W')
        b.w++;
    else if(a[i]=='E')
        b.e++;
}
if(b.s>0&&b.n>0&&b.e>0&&b.w>0)
    f=1;
else if((b.s>0&&b.n>0)&&(b.e+b.w==0))
    f=1;
else if((b.s+b.n==0)&&b.e>0&&b.w>0)
    f=1;
else f=0;
if(f==1)
    printf ("Yes");
else if(f==0)
    printf ("No");
}

不难,只要W E S N都大于0+特殊情况就可以了

import re import subprocess import requests import json from pprint import pprint url = "https://www.bilibili.com/video/BV1fi4y1K7Na/?spm_id_from=333.1007.top_right_bar_window_default_collection.content.click&vd_source=4545a0e83c576b93b1abd0ca4e16ab4d" headers = { "referer": "https://www.bilibili.com/", "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36", "cookie":"i-wanna-go-back=-1; _uuid=C106610D104-6D27-6584-66E1-FCDE2859156A75277infoc; FEED_LIVE_VERSION=V8; home_feed_column=5; buvid3=D2AE610A6-6EE7-B48E-10C51-9E8269B10C88776898infoc; header_theme_version=CLOSE; DedeUserID=1852701166; DedeUserID__ckMd5=ac9474243bdd3627; nostalgia_conf=-1; CURRENT_PID=e16a0380-e1cd-11ed-a872-2f97008834b2; rpdid=|(k|k~u|)RY)0J'uY)kkl|m)m; b_ut=5; browser_resolution=1482-792; CURRENT_BLACKGAP=0; buvid_fp_plain=undefined; CURRENT_FNVAL=4048; b_nut=1683881044; hit-new-style-dyn=1; hit-dyn-v2=1; SESSDATA=3e3851ea%2C1704423625%2C1959b%2A72SteLEoaNhz8Q6ifKiYFGRpSBjpMp2TG-QWAao2iv2yR5ci81QOokmXevCx102rLpwUc9qgAAQgA; bili_jct=2ea1af9f8ae6f19867c8cd3dc1bfd047; fingerprint=dd5c1878758a4b317420b66dad49b677; b_lsid=97F1E5C5_1894440C9F1; buvid4=9D5A25A5-A648-0805-4C59-8178C4E4362B31067-023042319-0THAXXn9jKfRyf3rDh/fQA%3D%3D; buvid_fp=dd5c1878758a4b317420b66dad49b677; sid=7i4lnopc; bp_video_offset_1852701166=817021346575810700; PVID=1" } response = requests.get(url, headers=headers) name = re.findall('"title":"(.*?)"',response.text)[0].replace(' ','') html_data = re.findall('<script>window.__playinfo__=(.*?)</script>',response.text)[0] json_data = json.loads(html_data) #print(name) # print(html_data) # print(json_data) # pprint(json_data) audio_url = json_data['data']['dash']['audio'][0]['baseUrl'] video_url = json_data['data']['dash']['video'][0]['baseUrl'] # print(audio_url) # print(video_url) audio_content = requests.get(url=audio_url,headers=headers).content video_content = requests.get(url=video_url,headers=headers).content with open("D:\\study\\B站\\素材\\" + name + ".mp3", mode="wb") as audio: audio.write(audio_content) with open("D:\\study\\B站\\素材\\" + name + ".mp4", mode="wb") as video: video.write(video_content) cmd = f'ffmpeg -i D:\\study\\B站\\素材\\{name}.mp4 -i D:\\study\\B站\\素材\\{name}.mp3 -c:a aac -strict experimental D:\\study\\B站\\视频1080P\\{name}output.mp4' subprocess.run(cmd)
07-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值