坑。http://codeforces.com/contest/245/problem/B

B. Internet Address
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:

<protocol>://<domain>.ru[/<context>]

where:

  • <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes),
  • <domain>is a non-empty string, consisting of lowercase English letters,
  • the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters.

If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context).

When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".".

Help Vasya to restore the possible address of the recorded Internet resource.

Input

The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only.

It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above.

Output

Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them.

Sample test(s)
Input
httpsunrux

Output
http://sun.ru/x

Input
ftphttprururu

Output
ftp://http.ru/ruru

Note

In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".

水题一枚:

View Code

 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     char str[60];
 6     char ans1[5],ans2[60],ans3[60];
 7     while(~scanf("%s",str))
 8     {
 9         int i;
10         if(str[0]=='f')
11         {
12             printf("ftp://");
13             i=3;
14         }
15         else
16         {
17             printf("http://");
18             i=4;
19         }
20         int flag=0,flag2=0;
21         int len=strlen(str);
22         printf("%c",str[i]);
23                 /*
24                 <domain> is a non-empty string
25                 至少一个字符先输出
26                 这里害坑了我
27                 */
28         for(int j=i+1;str[j]!='\0';j++)
29         {
30
31             if(flag==0&&str[j]=='r'&&str[j+1]=='u')
32             {
33                 printf(".ru");
34                 /*
35                 之前写成这样
36                 printf(".ru/");
37                 错了,后面可能为空,空不需要"/"
38                                 所以在后面判断
39                 */
40                 j++;
41                 flag=1;
42                 if(flag2==0&&j!=len-1)
43                 {
44                     printf("/");
45                     flag2=1;
46                 }
47             }
48             else
49             printf("%c",str[j]);
50
51         }
52         printf("\n");
53
54     }
55 }

转载于:https://www.cnblogs.com/1114250779boke/archive/2012/11/20/2778881.html

cf B. Internet Address相关推荐

  1. C - Internet Address CodeForces - 245B(有些思维的水题)

    Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote ...

  2. 响应因特网端口ping命令_如何使用Ping命令识别基本的Internet问题

    响应因特网端口ping命令 Next time you call your help desk, do you want to wow them with your networking knowle ...

  3. 如何限制某些用户发送Internet邮件

    1.打开Names.nsf数据库,然后却换到服务器配置 然后编辑配置,切换到Router/SMTP--Restrications and controls-Smtp outbound controls ...

  4. 22.4. IP Address

    <WA2220E-AG>system-view System View: return to User View with Ctrl+Z. [WA2220E-AG]interface vl ...

  5. sybase 珍藏(五)

    sybase配置 配置SYBASE服务器 1. 为SYBASE SERVER创建所需的设备 建议将sybase server的数据库设备创建在裸设备上,因此,在系统中创建以下逻辑卷: lvname=m ...

  6. H3CNE考试模拟试题

    1. 以下工作于OSI 参考模型数据链路层的设备是__A____.(选择一项或多项) A. 广域网交换机    B. 路由器    C. 中继器    D. 集线器 * A 数据链路层传输的是帧,交换 ...

  7. mds部署服务器系统,Windows服务器2003年对MDS/IPS-8配置示例的iSCSI主机

    目录 简介 Cisco的iSCSI驱动,在服务器上位于,是iSCSI解决方法的关键组件.这些iSCSI驱动程序拦截SCSI命令,将其封装到IP数据包中,并将其重定向到Cisco SN 5420.Cis ...

  8. FreeBSD开发手册(一)

    The FreeBSD Documentation Project FreeBSD 中文计划 版权 © 2000, 2001, 2002, 2003, 2004, 2005 The FreeBSD D ...

  9. 超级无敌qmail安装大法,详尽之极

    ---------------------------------------------------------------------------------------------------- ...

最新文章

  1. Tableau必知必会之学做一个实用的热图日历
  2. STL标准库-容器-set与map
  3. JMeter压测笔记
  4. SQL--Chapter8--Working with Triggers and Transactions
  5. css定位:相对定位
  6. mybatis依赖_这大概就是公司一直用Mybatis的原因!真的太强了
  7. JaveScript用二分法与普通遍历(冒泡)
  8. linux查看ps进程命令,linux ps查看进程命令
  9. lvs nginx-proxy nginx 取用户真实IP
  10. 【路径规划】基于matlab GUI粒子群算法机器人路径规划动画演示(手动设障)【含Matlab源码 924期】
  11. MySQL Client/Server Protocol
  12. 记忆训练 0-100的110个数字对应编码
  13. 为什么TIME_WAIT状态是2MSL?(2个原因)
  14. ESXi社区版ne1000 VIB驱动的更新
  15. 虚拟机kali挂主机代理
  16. 有什么好的论文查重软件?两分钟让你知道
  17. 第六讲 Linux字符设备驱动1
  18. 如何在三个月内创立一家估值200亿的游戏公司?
  19. easyui(权限系统)
  20. 局域网文件管理系统_生产设备日常巡检管理系统解决方案

热门文章

  1. Python数据结构与算法(1.2)——Python基础之变量与内置数据类型
  2. python参数检查类型_Python类型检查
  3. maps-api-v3_Android Google Maps API集成
  4. swift 二进制读写_Swift二进制搜索树
  5. scala编程_Scala编程语言简介
  6. 开课吧Java:构建微服务时的三大常见错误
  7. 什么是Hystrix,Hystrix简单概述
  8. Java基础:BufferedWriter和PushbackReader
  9. Java基础之如何修改字符串?
  10. Python基础笔记(二) List、tuple、循环语句