HDU 4081-Parsing URL(水)

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;
}
时间: 2024-12-19 08:05:28

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

hdu 4018 Parsing URL(字符串截取)

题目 以下引用自百度百科: sscanf 的相关用法 头文件:#include<stdio.h> 1. 常见用法. 1 2 3 charbuf[512]; sscanf("123456","%s",buf);//此处buf是数组名,它的意思是将123456以%s的形式存入buf中! printf("%s\n",buf); 结果为:123456 2. 取指定长度的字符串.如在下例中,取最大长度为4字节的字符串. 1 2 sscanf(&

HDU 4081 Qin Shi Huang&#39;s National Road System 最小生成树

分析:http://www.cnblogs.com/wally/archive/2013/02/04/2892194.html 这个题就是多一个限制,就是求包含每条边的最小生成树,这个求出原始最小生成树然后查询就好了 然后预处理那个数组是O(n^2)的,这样总时间复杂度是O(n^2+m) 这是因为这个题n比较小,如果n大的时候,就需要路径查询了,比如LCA 或者树链剖分达到O(mlogn) #include <iostream> #include <algorithm> #incl

Parsing URL

Parsing URL Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 1693    Accepted Submission(s): 864 Problem Description In computing, a Uniform Resource Locator or Universal Resource Locator (URL)

HDU 4081 Qin Shi Huang&#39;s National Road System

https://vjudge.net/problem/HDU-4081 题意: 秦始皇想要修长城,修成生成树的样子,这是一个大师出现了,他说他可以不耗费人力修出一条路来.他们的目的很不一样,神特么有分歧,最后他们达成了一个协议,假设一个城市的人口为a.那么最后不耗费人力修的那条路所相连的两个城市的人力之和A与修路花费的人力B之比 A/B最大,并且输出最大值. 思路: 枚举去掉每一条边. 首先求出最小生成树,对于最小生成树中的每一条边,如果这条边不花费人力,那么直接计算A和B就可以了. 那么问题是

hdu 4081 Qin Shi Huang&#39;s National Road System(最小生成树+dp)

同样是看别人题解才明白的 题目大意—— 话说秦始皇统一六国之后,打算修路.他要用n-1条路,将n个城市连接起来,并且使这n-1条路的距离之和最短.最小生成树是不是?不对,还有呢.接着,一个自称徐福的游方道士突然出现,他说他可以不消耗任何人力财力,使用法术凭空造一条路,路的长度无所谓,但是只能造一条.那么问题来了,徐福希望将两座人口数最多的城市连接起来,而秦始皇希望将最长的路修好.最后折中了一下, 将A/B最大的一条路用法术修出来.其中A是两座城市的人口和,B是除了用法术修的路以外,其它需要修建的

简单的dp hdu 数塔(水题)

数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 21314    Accepted Submission(s): 12808 Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少

hdu 2053 Switch Game 水题一枚,鉴定完毕

Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10200    Accepted Submission(s): 6175 Problem Description There are many lamps in a line. All of them are off at first. A series of op

HDU 2090 算菜价 --- 水题

/* HDU 2090 算菜价 --- 水题 */ #include <cstdio> int main() { char s[105]; double a, b, sum = 0; while (scanf("%s", s)==1){ scanf("%lf%lf", &a, &b); a *= b; sum += a; } printf("%.1f\n", sum); return 0; }

HDU 2091 空心三角形 --- 水题

/* HDU 2091 空心三角形 --- 水题 */ #include <cstdio> int main() { int kase = 0; char ch; int h, t; //h表示高 while (scanf("%c", &ch) == 1 && ch != '@'){ scanf("%d", &h); if (kase++){ printf("\n"); } getchar(); if