努力ing
你浪费的今天是昨天死去的人所渴望的明天!!!

随笔分类 -  hdu基础题

HDU 2547 无剑无我
摘要:其实就是求两点的距离#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 阅读(223) 评论(0) 推荐(0)
HDU 1283
摘要: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 阅读(124) 评论(0) 推荐(0)
HDU 1013
摘要: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 阅读(161) 评论(0) 推荐(0)
HDU 1002
摘要: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 阅读(134) 评论(0) 推荐(0)
HDU 1004
摘要:#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 阅读(99) 评论(0) 推荐(0)
HDU 1070
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1070#include<iostream>#include<string>#include<algorithm>#include<vector>using namespace std;struct node { string str; int m; int v; int day; double s;};double cmp(node& x,node& y){ if(x.s!=y.s) return x.s<y.s; else return 阅读全文
posted @ 2013-05-27 17:37 努力ing 阅读(154) 评论(0) 推荐(0)
hdu 1246 自共轭Ferrers图
摘要:是道数学类的简单题#include<iostream>using namespace std;int main(){ int n; int a[305]; memset(a,0,sizeof(a)); a[0]=a[1]=1; int i,j; for(i=3;i<305;i+=2) //基数是共轭的 { for(j=305-i;j>=0;j--) { a[i+j]+=a[j]; //基数加偶数还是基数,所以共轭,基数加基数是偶数,还是共轭的 } } w... 阅读全文
posted @ 2013-05-11 15:55 努力ing 阅读(246) 评论(0) 推荐(0)
hdu1106
摘要:学会用函数strtok,功能:函数返回字符串str1中紧接“标记”的部分的指针, 字符串str2是作为标记的分隔符。如果分隔标记没有找到,函数返回NULL。为了将字符串转换成标记,第一次调用str1 指向作为标记的分隔符。之后所以的调用str1 都应为NULL。例如: char str[] = "now # is the time for all # good men to come to the # aid of their country"; char delims[] = "#"; char *result = NULL result = strt 阅读全文
posted @ 2013-05-07 13:26 努力ing 阅读(104) 评论(0) 推荐(0)
HDU1076
摘要:刷一刷水题,找回自信啊!#include<iostream>using namespace std;int main(){int y,n;int t;cin>>t;while(t--){cin>>y>>n;int temp=0;while(1){if(y%400==0||(y%4==0&&y%100!=0))temp++;if(temp==n)break;y++;}cout<<y<<endl;}return 0;} 阅读全文
posted @ 2013-05-06 08:48 努力ing 阅读(100) 评论(0) 推荐(0)