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
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.
For each of test case, there is only one line contains a valid URL.
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
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(水)的更多相关文章
- hdu 4018 Parsing URL(字符串截取)
题目 以下引用自百度百科: sscanf 的相关用法 头文件:#include<stdio.h> 1. 常见用法. 1 2 3 charbuf[512]; sscanf(" ...
- Qin Shi Huang's National Road System HDU - 4081(树形dp+最小生成树)
Qin Shi Huang's National Road System HDU - 4081 感觉这道题和hdu4756很像... 求最小生成树里面删去一边E1 再加一边E2 求该边两顶点权值和除以 ...
- hdu 4940 数据太水...
http://acm.hdu.edu.cn/showproblem.php?pid=4940 给出一个有向强连通图,每条边有两个值分别是破坏该边的代价和把该边建成无向边的代价(建立无向边的前提是删除该 ...
- HDU - 4081 Qin Shi Huang's National Road System 【次小生成树】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4081 题意 给出n个城市的坐标 以及 每个城市里面有多少人 秦始皇想造路 让每个城市都连通 (直接或者 ...
- 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: ...
- 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 ...
- hdu 4081 Qin Shi Huang's National Road System(次小生成树prim)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4081 题意:有n个城市,秦始皇要修用n-1条路把它们连起来,要求从任一点出发,都可以到达其它的任意点. ...
- hdu 1106:排序(水题,字符串处理 + 排序)
排序 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...
- HDU 4950 Monster (水题)
Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...
随机推荐
- siwft初学(一)
今天刚開始学习swift语言.首先须要下载xcode6 beta版本号.正式版本号然后会公布.自己学习总结一下,假设有误.请大家指出. 创建project的时候.language选择swift语言. ...
- HDU 4337 King Arthur's Knights 它输出一个哈密顿电路
n积分m文章无向边 它输出一个哈密顿电路 #include <cstdio> #include <cstring> #include <iostream> usin ...
- C++ Primer 学习笔记_40_STL实践与分析(14)--概要、先来看看算法【上】
STL实践与分析 --概述.初窥算法[上] 标准库容器定义的操作很少.并没有给容器加入大量的功能函数.而是选择提供一组算法,这些算法大都不依赖特定的容器类型,是"泛型"的. ...
- WPF/Silverlight中图形的平移,缩放,旋转,倾斜变换演示
原文:WPF/Silverlight中图形的平移,缩放,旋转,倾斜变换演示 为方便描述, 这里仅以正方形来做演示, 其他图形从略. 运行时效果图:XAML代码:// Transform.XAML< ...
- bzoj 1874 取石子游戏 题解 & SG函数初探
[原题] 1874: [BeiJing2009 WinterCamp]取石子游戏 Time Limit: 5 Sec Memory Limit: 162 MB Submit: 334 Solved ...
- 使用Jfree实现吧条形图,java代码
使用Jfree实现吧条形图,java代码.它可能在生产的报告被常用,之后,主动生成自己的代码,可以随意查看.自由地配置图表的各种性质,为了达到他们的要求和目标 package test1; impor ...
- [LeetCode141]Linked List Cycle
题目:Given a linked list, determine if it has a cycle in it. 判断一个链表是否有环 代码: /** * Definition for singl ...
- NGUI简单背包系统的实现
一.利用txt文件存储游戏物品信息 首先在asset下创建一个txt文件,这里我们命名为objectsInfoList.txt,并将其拖放到unity Project视图中. 其中txt中我们先存放一 ...
- UVa11488-Hyper Prefix Sets(trie树)
H Hyper Prefix Sets Prefix goodness of a set string is length of longest common prefix*number of str ...
- ios说说自己的计划是什么样的发展论坛
ios发展论坛在显示 iOS 5 在,主界面包含以下内置的应用程序: 信息.日历.照片. YouTube.股市.地图(AGPS辅助的Google地图).天气.时间.计算机.备忘录.系统设置. ...