Parsing URL

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)

Total Submission(s): 1575    Accepted Submission(s): 796

Problem Description
In computing, a Uniform Resource Locator or Universal Resource Locator (URL) is a character string that specifies where a known resource is available on the Internet and the mechanism for retrieving it.

The syntax of a typical URL is:

scheme://domain:port/path?query_string#fragment_id

In this problem, the scheme, domain is required by all URL and other components are optional. That is, for example, the following are all correct urls:

http://dict.bing.com.cn/#%E5%B0%8F%E6%95%B0%E7%82%B9

http://www.mariowiki.com/Mushroom

https://mail.google.com/mail/?shva=1#inbox

http://en.wikipedia.org/wiki/Bowser_(character)

ftp://fs.fudan.edu.cn/

telnet://bbs.fudan.edu.cn/

http://mail.bashu.cn:8080/BsOnline/

Your task is to find the domain for all given URLs.
 
Input
There are multiple test cases in this problem. The first line of input contains a single integer denoting the number of test cases.

For each of test case, there is only one line contains a valid URL.
 
Output
For each test case, you should output the domain of the given URL.
 
Sample Input
3
http://dict.bing.com.cn/#%E5%B0%8F%E6%95%B0%E7%82%B9
http://www.mariowiki.com/Mushroom
https://mail.google.com/mail/?shva=1#inbox
 
Sample Output
Case #1: dict.bing.com.cn
Case #2: www.mariowiki.com
Case #3: mail.google.com
训练一下高速找到水题并切掉的能力。。毕竟现场赛仅仅能做水题了。 。7分钟1A
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
#define LL long long
char s[10010],ans[10010];
int main()
{
//ios::sync_with_stdio(false);
int t,p,cas=1;
scanf("%d",&t);
getchar();
while(t--)
{
gets(s);
int len=strlen(s);
for(int i=0;i<len;i++)
{
if(s[i]=='/'&&s[i-1]=='/')
{
int j=i+1;p=0;
while(s[j]!='/'&&s[j]!=':')
ans[p++]=s[j++];
break;
}
}
printf("Case #%d: ",cas++);
for(int i=0;i<p;i++)
printf("%c",ans[i]);
puts("");
}
return 0;
}

版权声明:本文博客原创文章。博客,未经同意,不得转载。

HDU 4081-Parsing URL(水)的更多相关文章

  1. hdu 4018 Parsing URL(字符串截取)

    题目 以下引用自百度百科: sscanf 的相关用法 头文件:#include<stdio.h>     1. 常见用法. 1 2 3 charbuf[512]; sscanf(" ...

  2. Qin Shi Huang's National Road System HDU - 4081(树形dp+最小生成树)

    Qin Shi Huang's National Road System HDU - 4081 感觉这道题和hdu4756很像... 求最小生成树里面删去一边E1 再加一边E2 求该边两顶点权值和除以 ...

  3. hdu 4940 数据太水...

    http://acm.hdu.edu.cn/showproblem.php?pid=4940 给出一个有向强连通图,每条边有两个值分别是破坏该边的代价和把该边建成无向边的代价(建立无向边的前提是删除该 ...

  4. HDU - 4081 Qin Shi Huang's National Road System 【次小生成树】

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4081 题意 给出n个城市的坐标 以及 每个城市里面有多少人 秦始皇想造路 让每个城市都连通 (直接或者 ...

  5. HDU 4081 Qin Shi Huang's National Road System 最小生成树+倍增求LCA

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4081 Qin Shi Huang's National Road System Time Limit: ...

  6. LA 5713 - Qin Shi Huang's National Road System(HDU 4081) MST

    LA:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...

  7. hdu 4081 Qin Shi Huang's National Road System(次小生成树prim)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4081 题意:有n个城市,秦始皇要修用n-1条路把它们连起来,要求从任一点出发,都可以到达其它的任意点. ...

  8. hdu 1106:排序(水题,字符串处理 + 排序)

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  9. HDU 4950 Monster (水题)

    Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...

随机推荐

  1. hdu 2191 悼念512四川汶川大地震遇难者——如今宝,感恩生活

    悼念512四川汶川大地震遇难者--如今宝,感恩生活 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  2. 你怎么知道你的网站K

    最近有朋友问我关于网站K问题,你怎么知道被提及哪些网站K方面.总结了六个方法后,,至于有没有其他办法.欢迎和我交流讨论. 检测方法是网站的搜索引擎惩罚:   首先要明白的是.搜索引擎不惩罚easy侦查 ...

  3. 这么多的技术,作为一个freshman,什么研究?

    科学技术,从哪里学习?        杨问了我几个最近:"如何学习技术?".说实话,其实,我自己只是一个资深兄弟.对于这个答案.这是更难以在本身回答. 可是.既然比师弟们多吃了几年 ...

  4. 深度this指针

    深入探讨this指针   为了写这篇文章.准备了好长时间,翻遍了箱底的书籍.可是如今还是不敢放开手来写,战战兢兢. 不是操心自己写错.而是唯恐自己错误误导别人.同一时候也希望这篇文章能给你一点收获.既 ...

  5. Memcahce(MC)系列(两)Linux下一个Memcache安装

    Linux下一个memcache安装 memcache是高性能.分布式的内存对象缓存系统,用于在动态应用中降低数据库负载.提升訪问速度.眼下用memcache解决互联网上的大用户读取是很流行的一种使用 ...

  6. 原生javascript与jquery 的比较

    JavaScript的优点和缺点: 优点: 性能:由于JavaScript运行在客户端,节省了web服务器的请求时间和带宽 轻量级的脚本语言,比较容易学习 运行在用户机器上,运行结果和处理相对比较快. ...

  7. 文件翻译002片:Process Monitor帮助文档(Part 2)

    [筛选亮点] Process Monitor提供了一些方式来配置筛选器和高亮显示.         筛选器的包括与排除 您能够在筛选器中指定事件的属性,这样就能够令Process Monitor仅显示 ...

  8. 使用MySQL Workbench建立数据库,建立新的表,向表中添加数据

    使用MySQL Workbench建立数据库,建立新的表,向表中添加数据 初学数据库,记录一下所学的知识.我用的MySQL数据库,使用MySQL Workbench管理.下面简单介绍一下如何使用MyS ...

  9. redis(Remote Dictionary Server)

    redis的简介和使用   简介 redis(Remote Dictionary Server)是一种Nosql技术,它是一个开源的高级kv存储和数据结构存储系统,它经常被拿来和Memcached相比 ...

  10. 不用库(框架),自己写ajax

    平常会使用ajax来请求数据,加载一个库(框架),或许仅仅maybe就使用了它的ajax部分. 写个ajax,一来可以经历一下处理问题的过程,提升技术能力,二来工作中有时真的用不着这么大的一个库(框架 ...