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. mysql copy复制拷贝表数据及结构的几种方式(转)

    mysql拷贝表操作我们会常常用到,下面就为您详细介绍几种mysql拷贝表的方式,希望对您学习mysql拷贝表方面能够有所帮助.假如我们有以下这样一个表:id username password--- ...

  2. JBOSS EAP6.2.0的下载安装、环境变量配置以及部署

    JBOSS EAP6.2.0的下载安装.环境变量配置以及部署 JBoss是纯Java的EJB(企业JavaBean)server. 第一步:下载安装 1.进入官网http://www.jboss.or ...

  3. Oracle SQL Lesson (11) - 创建其他数据库对象(试图/序列/索引/同义词)

    schema(模式)一个用户下一组对象的集合,一般与用户名一致. 视图 CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view [(alias[, alias].. ...

  4. Hibernate4.3.9Final常见问题汇总

    hibernate4下一个可用的hibernate.properties: jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql ...

  5. Mac下改动Android Studio 所用的JDK版本号

    Mac下改动Android Studio 所用的JDK版本号 @author ASCE1885 近期项目从Eclipse+Ant构建模式转移到了Android Studio+Gradle构建模式.自然 ...

  6. mac_Mac环境下怎样编写HTML代码?

    在Mac环境下,使用默认的文本编辑器编写的HTML的源代码, 使用不同的浏览器打开后,依旧还是显示源代码 推荐使用UltraEdit,问题就迎刃而解了

  7. effective c++ 条款12 copy all parts of an object

    这经常发生在更改代码的时候,当有自己的copy 赋值函数或者copy 构造函数时,编译器就不会维护这两个函数.导致发生遗忘. 可能出现的场景 class Customer { private: std ...

  8. 制作简易计算器处理过程Servlet

    CalculationServlet.java: package com.you.servlet; import java.io.IOException; import java.io.PrintWr ...

  9. UVA How Big Is It?

    题目例如以下: How Big Is It?  Ian's going to California, and he has to pack his things, including hiscolle ...

  10. 左右presentViewController经background黑问题

    看效果图: 用例如以下代码,想弹出一个模态窗体,设置它的背景透明度为0.5,却发觉prsent后的背景色变为黑色的. ShareVC *share = [[ShareVC alloc] init]; ...