努力ing
你浪费的今天是昨天死去的人所渴望的明天!!!
摘要: 其实就是求两点的距离#include #include #include using namespace std;int main(){ int t; double a,b,c,d; double min,k1,k2; cin>>t; while(t--) { cin>>a>>b>>c>>d; if(a>c) k1=(a-c)/2; else k1=(c-a)/2; if(b>d) k2=(b-d)/2; else k2=(d-b)/2; min=2*sqrt(k1*k1+k2*k2); printf("%.1l 阅读全文
posted @ 2013-06-25 17:53 努力ing 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 简单的动态规划题目#include using namespace std;struct node { int s,e,v;};int dp[105];int main(){ node job[1005]; int n,m,t; int i,j; cin>>t; while(t--) { cin>>m>>n; for(i=0;i>job[i].s>>job[i].e>>job[i].v; for(i=0;i<=m;i++) dp[i]=0; for(i=1;i<=m;i++) { for(j=0;j<n;j++ 阅读全文
posted @ 2013-06-25 17:11 努力ing 阅读(157) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3177#include<iostream>#include "algorithm"using namespace std;struct node { int ai; int bi; int ci; bool operator <(const node& x) { return ci>x.ci; //排序两者的差值 }};int main(){ int t,i,j; int v,n; cin>>t; node job[10005]; while(t 阅读全文
posted @ 2013-06-21 17:23 努力ing 阅读(141) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<algorithm>#include<cstring>using namespace std;struct node { int day; int score; bool operator<(const node& x)const{ return score>x.score; }};int main(){ int t,n; int i,j,ans; cin>>t; node job[5005]; int flag[5005]; while(t--) { cin>> 阅读全文
posted @ 2013-06-21 13:31 努力ing 阅读(183) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4552dp#include<iostream>#include<string>using namespace std;int main(){ string str; int i,j,k; while(cin>>str) { int count=0; int t=str.length(); for(i=0;i<t;i++) { for(j=0,k=i;j<t;j++,k++) { if(str[j]!=str[k]) break; } count+=j; } co 阅读全文
posted @ 2013-06-01 10:52 努力ing 阅读(124) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1283#include<iostream>#include<string>using namespace std;int main(){ int m1,m2; string str; while(cin>>m1>>m2>>str) { int r1=0,r2=0,r3=0,i; int t=str.length(); for(i=0;i<t;i++) { if(str[i]=='A') {r1=m1;continue;} if( 阅读全文
posted @ 2013-05-30 22:32 努力ing 阅读(121) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1013题目简述:输入一串数字,求它的根,根的定义:将各位数字相加,如果和小于10,则为根,否则,继续将和的各位数相加,知道和小于10.Input24390Output63代码:解释(sum-1)%9+1;如果要将一个数n变成1~9之间的数,(n-1)%9+1就行了举个例子吧!假如输入的数是7896768;可以这样做:(7+8+9+6+7+6+8-1)%9+1=6;代码:#include<iostream>#include<string>using namespace std;int m 阅读全文
posted @ 2013-05-30 20:55 努力ing 阅读(160) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1002#include<iostream>#include<string>using namespace std;int main(){ int n; scanf("%d",&n); int i; for(i=1;i<=n;i++) { string str1,str2; cin>>str1>>str2; int a[1010]={0},b[1010]={0},c[1010]={0}; int j,k; int alen=str 阅读全文
posted @ 2013-05-30 20:43 努力ing 阅读(130) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<string>using namespace std;int main(){ int i,j,n; while(cin>>n&&n) { string str[1005]; int num[1005]={0}; for(i=0;i<n;i++) { cin>>str[i]; for(j=0;j<=i;j++) { if(str[i]==str[j]) num[j]++; } } int max=-1; int k; for(i=0;i<n;i++) if(ma 阅读全文
posted @ 2013-05-30 20:42 努力ing 阅读(94) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1088字符串问题第一种方法#include<iostream>#include<string>using namespace std;int main(){ string str; int i,num=0; while(cin>>str) { if(str=="<br>") { cout<<endl; num=0; continue; } if(str=="<hr>") { if(num!=0) c 阅读全文
posted @ 2013-05-30 20:40 努力ing 阅读(195) 评论(0) 推荐(0) 编辑