BerOS file system CodeForces - 20A

File System Filter C Source Code 文件过滤驱动C源代码 文件过滤驱动C源代码 文件过滤驱动C源代码 立即下载

BerOS file system

CodeForces - 20A

The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equivalent. The character '/' (or some sequence of such characters) at the end of the path is required only in case of the path to the root directory, which can be represented as single character '/'.

A path called normalized if it contains the smallest possible number of characters '/'.

Your task is to transform a given path to the normalized form.

Input

The first line of the input contains only lowercase Latin letters and character '/' — the path to some directory. All paths start with at least one character '/'. The length of the given line is no more than 100 characters, it is not empty.

Output

The path in normalized form.

Example
Input
//usr///local//nginx/sbin
Output
/usr/local/nginx/sbin
给你一个 字符数不超过100的 仅由小写字母与字符'/'构成的 字符串
然后把字符串的一些不必要的字符去掉了
  1.如果出现连续的'/'那么只需要一个'/'即可 
  2.把路径名最后面那些'/'去掉了,除非路径名仅由一个'/'组成

code:

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
char str[1100];
int main(){
    while(~scanf("%s",str)){
        int len = strlen(str);
        for(int i = 0; i < len; i++){
            if(str[i] == '/'){
                i++;
                while(i < len && str[i] == '/'){
                    str[i] = '.';
                    i++;
                }
                i--;
            }
        }
        int k = 0;
        char ans[1000];
        for(int i = 0; i < len; i++){
            if(str[i] != '.'){
                ans[k++] = str[i];
            }
        }
        while(k > 0 && ans[k-1] == '/') k--;
        ans[k] = 0;
        if(k == 0) printf("/\n");
        else printf("%s\n",ans);
    }
    return 0;
}



工业互联网工控安全与工业质检AI大模型建设方案.pptx 立即下载

相关推荐

【CATIA的二次开发38】对象Selection交互选择部分方法介绍01

在CATIA V5的VBA开发中,Selection对象是用户交互的核心组件,用于管理用户在图形区域或特征树中的选择操作。Selection 对象是 CATIA VBA 中的中央交互枢纽,充当用户界面与程序逻辑之间的桥梁。它代表当前在图形区域或特征树中被选中的元素集合,是自动化操作的基础。

学习共勉:不积跬步,无以至千里; 不积小流,无以成江海。 1337

BerOS File Suggestion

题意: 给出几个字符串,再给出几个字符串,找这些字符串在前面已给出自符串的母串有几个,输出母串个数及任意一个母串; 题解: 直接暴力,超时;每个字符串长度最大为8 ,所以把每个字符串拆成子串,用map存起来,再输入所要查找的字符串时,直接找就行。 Description Polycarp is working on a new operating system called BerOS....

G-Howe的博客 520

细说STM32单片机SPI-Flash芯片的FatFS移植及其应用实例详解

本文以开发板上的SPI-Flash芯片W25Q16为媒介详细介绍CubeMX中FatFS各个参数的意义和设置,分析生成的代码中FatFS各个文件的作用和关联,完成针对W25Q16的硬件访问层的移植。继续使用旺宝红龙开发板STM32F407ZGT6 KITV1.0。

wenchm的博客 1637

CodeForces刷题C语言:BerOS file system、Second Order Statistics、IQ test、Phone numbers、Almost Prime

记录CodeForcess刷题C语言QAQ。

林一百二十八的博客 1368

Trae IDE与Playwright MCP:5分钟实现零代码网页数据抓取

网页数据抓取是数据采集和自动化处理中的基础技术,其核心原理是通过程序模拟浏览器行为,定位并提取页面中的结构化信息。传统方式依赖编写脚本处理网络请求、解析HTML和应对反爬机制,技术门槛较高。而结合AI与自动化工具的新范式,通过自然语言交互即可完成复杂操作,极大降低了技术门槛并提升了开发效率。这种技术价值在于将开发者从繁琐的编码中解放,使其更专注于数据分析和业务逻辑。在数据监控、市场调研、竞品分析等应用场景中,快速获取网页数据是关键需求。本文以Trae IDE集成Playwright MCP为例,演示如何通过

culi3118的博客 498

手把手教你用STM32F103C8T6驱动HUB75 LED点阵屏(附74HC595级联代码)

本文详细介绍了如何使用STM32F103C8T6开发板驱动HUB75接口的LED点阵屏,包括硬件连接、74HC595级联代码、时序控制及灰度显示实现。通过实战案例展示动态文字显示和性能优化技巧,帮助开发者快速掌握LED点阵屏驱动技术。

weixin_42623010的博客 341

BerOS File Suggestion CodeForces - 1070H

Polycarp is working on a new operating system called BerOS. He asks you to help with implementation of a file suggestion feature. There are nn files on hard drive and their names are f1,f2,…,fnf1,f2,...

七九河开的博客 284

CISSP背书三次失败后的终极解决方案

本文分享了作者CISSP认证三次线上背书审核失败的经历与终极解决方案。针对(ISC)²官方审核的严格性,文章详细剖析了使用公积金证明、工作证明盖章签字等常见材料的误区,并最终提出了通过构建“官方邮件往来”证据链的核心策略,以动态、可验证的方式成功通过审核,为后来者提供了详实的避坑指南和实操清单。

weixin_29219539的博客 153

[codeforces1070H]BerOS File Suggestion

time limit per test : 3 seconds memory limit per test : 256 megabytes Polycarp is working on a new operating system called BerOS. He asks you to help with implementation of a file suggestion feature. ...

dxyinme-Zz 307

pymol 动画简单制作,gif、mp4导出

参考: https://www.youtube.com/watch?v=G77K9Lro8js1、直接Movie下Program下,Camera Loop下Nutate下选择,这里选择30degover4 sec;如果要动画过渡自然,可以在这4sec后面再Append 1sec;如果需要两个视角,既可以再把窗口蛋白定位到比如配体,不用管中间过程怎么定位过去配体,再Program下,Camera Loop下Nutate下选择,这里选择30degover4 sec添加;最后如果要整体形成个循环播放,可以在这4s

weixin_42357472的博客 8434

原理之(〇)3D Gaussian Splatting 数学原理与推导

3D Gaussian Splatting源于EWA的理论基础,本文重点从EWA模型出发,详细推导3D GS中的数学原理,加深对鱼眼相机畸变场景下的理解。

scott198512的博客 4157

Codeforces 20A. BerOS file system

Codeforces 20A. BerOS file system 传送门:https://codeforces.com/problemset/problem/20/A 题目大意: 其实呢,就是给你一个字符串,你要做的就是保证每个单词前面有且仅有一个 ’ / ’ 。 主要想法: 我的想法比较简单,直接暴力吧,把这个过程分成两步,第一步是把每个单词前面的多余的 ’ / ’ 去掉,这一步我称为除重。然...

ydfy_的博客 260

拼多多笔试真题-多多送快递(C++/Py/Java /Js/Go)

拼多多技术岗笔试 8月2号真题,拼多多笔试第三题【多多送快递】,提供详细思路讲解以及Java、C++、Python、Go、JavaScript多语言代码实现。拼多多笔试真题【多多送快递】多语言题解。

qq_45776114的博客 291

CodeForces 20A BerOS file system (简单题)

题目类型  简单题 题目意思 给你一个 字符数不超过100的 仅由小写字母与字符'/'构成的 字符串 然后把字符串的一些不必要的字符去掉了   1.如果出现连续的'/'那么只需要一个'/'即可    2.把路径名最后面那些'/'去掉了,除非路径名仅由一个'/'组成 解题方法 直接按意思构造结果串 参考代码

yunyouxi0's blog 884

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

CodeForces - 20A BerOS file system【水题】

题目链接:https://codeforces.com/contest/20/problem/A #include <iostream> using namespace std; static const int MAXN=100+10; char s[MAXN],ss[MAXN]; int main() { scanf("%s",s); int j=0; for(int i=0;s[i];i++) { if(s[i]=='/')

inv0ker的博客 175

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

cf 20a BerOS file system

#include #include using namespace std; int main() { string s; cin>>s; bool flag=false; int p=s.length()-1; while(s[p]=='/') p--; if(p==-1) s="/"; else

Stool_Monster的专栏 661

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

E - BerOS file system

The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx...

L427630的博客 334

BerOS 文件系统路径归一化问题及其 Python 实现

本文介绍了一个经典的路径归一化问题及其高效的 Python 实现。代码逻辑清晰、易于扩展,并在路径标准化领域具有实际应用价值。如果你对本文感兴趣,欢迎分享和讨论!

2403_89537385的博客 794

BerOS file system

The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//ngi...

weixin_30325487的博客 205

BerOS File Suggestion (Codeforces 1070H)

题目链接:  http://codeforces.com/problemset/problem/1070/H 思路:直接找的话,会时间超限,所以可以用map把上面输入的串的所有字串都记下来,用两个map,一个记录有几个串有匹配的,一个记录匹配的串是哪个。 #include&lt;cstdio&gt; #include&lt;iostream&gt; #include &lt;string&g...

September_的博客 702

H - BerOS File Suggestion

Description Polycarp is working on a new operating system called BerOS. He asks you to help with implementation of a file suggestion feature. There are n files on hard drive and their names are f 1 , ...

莉莉莉的博客 423

【水I/O】#20 A. BerOS file system

A. BerOS file system time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output The new operating system BerOS has a ni

CD's Coding 1366

Python解决codeforces ---- 7

第一题 20A A. BerOS file system time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output The new operating ...

我是传奇 378

20A BerOS file system

A. BerOS file system time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output The new operating system BerOS has a ni

memory_qianxiao的博客 538

A. BerOS file system

A. BerOS file systemtime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputThe new operating system BerOS has a nice feature. It is possible to use any nu

chaideyipi 570
上一篇: 移动距离(15 point(s))
下一篇: Laser CodeForces - 15B
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值