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. Red Gate系列之三 SQL Server 开发利器 SQL Prompt 5.3.4.1 Edition T-SQL智能感知分析器 完全破解+使用教程

    原文:Red Gate系列之三 SQL Server 开发利器 SQL Prompt 5.3.4.1 Edition T-SQL智能感知分析器 完全破解+使用教程 Red Gate系列之三 SQL S ...

  2. 【小白的java成长系列】——顶级类Object源代码分析

    首先来说一下api文档使用,api这个词对有一定开发经验的java编程人员来说是非常喜爱的~ java当然也提供了api开发文档,下载地址:http://www.oracle.com/technetw ...

  3. WPF命令參数CommandParameter

    XAML代码例如以下: <Window x:Class="Demo006.MainWindow" xmlns="http://schemas.microsoft.c ...

  4. C# Windows Phone 8 WP8 高级开发,制作不循环 Pivot ,图片(Gallery)导览不求人! 内附图文教学!!

    原文:C# Windows Phone 8 WP8 高级开发,制作不循环 Pivot ,图片(Gallery)导览不求人! 内附图文教学!! 一般我们在开发Winodws Phone APP 的时候往 ...

  5. state pattern

    6 状态模式总结 状态模式将一个对象在不同状态下的不同行为封装在一个个状态类中,通过设置不同的状态对象可以让环境对象拥有不同的行为,而状态转换的细节对于客户端而言是透明的,方便了客户端的使用.在实际开 ...

  6. google在线测试练习2

    Problem Given a list of space separated words, reverse the order of the words. Each line of text con ...

  7. DFA和trie特里实现敏感词过滤(python和c语言)

    今天的项目是与完成python开展,需要使用做关键词检查,筛选分类,使用前c语言做这种事情.有了线索,非常高效,内存小了,检查快. 到达python在,第一个想法是pip基于外观的c语言python特 ...

  8. HTC M7日文版HTL22刷机包 毒蛇2.5.0 ART NFC Sense6.0

    ROM介绍 日文版的蝰蛇2.5.0简短的介绍: *根据最新的M8蝰蛇版本号2.5.0 *经过我的朋友和机器测试.功能是否正常,当然,并非所有的功能进行测试,以,假设遇到BUG请反馈 *删除国外社会.谷 ...

  9. 网站压力测试工具Webbench介绍

    webbench简单介绍: webbench是由 Lionbridge公司开发的出色的站点压力測试工具.它能測试处在同样硬件上,不同服务的性能以及不同硬件上同一个服务的执行状况.webbench不但能 ...

  10. Javascript作用域问题的构造函数的变量

    构造函数new对于使用.代表创建对象.此外,它可以被用作普通的函数调用,因为它也是一个功能. function Person(name) { this.name=name; } Person(12); ...