分析:自从有了set、sstream中的istringstream与及string之后,这种问题也变水了,记得不要忘了STL或者是字符串类及字符流等工具哦!、
注意:重复的单词算一个。
#include
#include
#include
using namespace std;
int main()
{
char a[10001];
string b;
while(gets(a) ...
分类:
其他好文 时间:
2015-04-27 09:53:49
阅读次数:
105
分析:贪心,每次优先取需要食物的重量和猫食的重量相比最大的,所以先要按比值进行排序,注意J[i]和B[i]要声明为实型,声明为整形就挂了。
#include
#include
using namespace std;
struct FAT
{
double f,j;
double avg;
} fat[1005];
bool cmp(FAT a,FAT b)
{
if(a.av...
分类:
其他好文 时间:
2015-04-27 09:50:08
阅读次数:
84
分析:模版题,直接套用模版即可。
#include
#include
using namespace std;
int u[2002];
int v[2002];
int w[2002];
bool vis[202];
int d[202];
int first[202];
int Next[2002];
void Init(int n,int m)
{
int i;
...
分类:
其他好文 时间:
2015-04-27 09:50:06
阅读次数:
87
虽然是水题,一开始也错了好多次,真是坑啊!
#include
using namespace std;
char a[101];
char c[26];
bool index[26];
void create()
{
int i,j;
memset(index,0,sizeof(index));
for(i=0;i<strlen(a);i++)
...
分类:
Web程序 时间:
2015-04-26 22:55:08
阅读次数:
172
水题,水水更健康。
#include
using namespace std;
int a[101][101];
void Show(int x)
{
int i,j,m,n;
memset(a,0,sizeof(a));
i=1;
m=1;
j=2;
n=x;
while(i<=n) a[1][i++]=m++;
while(j<=n) a[j++][n]=m++;
...
分类:
其他好文 时间:
2015-04-26 22:50:50
阅读次数:
157
分析:水题,但要注意当c取2*b时,a可能被c整除,此时a继续加b继续判断。
#include
using namespace std;
int gcd(int a,int b)
{
int r;
while(b)
{
r=a%b;
a=b;
b=r;
}
return a;
}
int get(int a,int b)
{
int c;
c=2*b;
wh...
分类:
其他好文 时间:
2015-04-26 22:47:52
阅读次数:
147
题意:有一个起始站点,从这里送n个学生去其余的n-1个站点邀请人们去CSS,然后再返回CSS,使得总的花费最小。注意每次只能送一个,返回时每次也只能送一个,而且每条路是单向的。
分析:这相当于一个有向图,我们只需两次调用SPFA算法即可,第一次求出初始站点(在这里是1)到其它所有站点的最小花费,然后相加;第二次将图反向建立,即所有的边反向,再求出初始站点(这里是1)到其它站点的最小费用,之后相加...
分类:
编程语言 时间:
2015-04-26 16:46:25
阅读次数:
213
The Balance
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6304 Accepted Submission(s): 2592
Problem Description
Now you are asked ...
分类:
其他好文 时间:
2015-04-26 13:53:41
阅读次数:
211
Big Event in HDU
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 26957 Accepted Submission(s): 9504
Problem Description
Nowadays, w...
分类:
其他好文 时间:
2015-04-26 09:26:05
阅读次数:
101
分析:首先求强连通分量的个数,然后进行缩点,最后求出最终答案。
1、求强连通分量的个数使用tarjan算法。
2、缩点为另外一个图,通过tarjan算法求出的结果进行。缩点后的图中求出每个点的入度。
3、求出每个强连通分量中的最小花费。
4、根据缩点后图的入度求出最终结果。
#include
#include
#include
using namespace std;
vect...
分类:
编程语言 时间:
2015-04-25 15:12:01
阅读次数:
182