摘要: View Code //从反面考虑:就是一个offer都没获得,最后结果p=1-p;#include"iostream"#include"algorithm"using namespace std;struct offer{ int a; double b;}s[10000];int cmp(offer x, offer y){ return x.b>y.b;}int main(){ int n,m; int i; while(cin>>n>>m,n+m) { for(i=0;i<m;i++) scanf(" 阅读全文
posted @ 2011-04-22 19:42 聊聊IT那些事 阅读(1293) 评论(1) 推荐(1) 编辑
摘要: 纯规律题:找到n=3时,分割数为20,从而可发现2,8, 20之间差的关系正好是6的倍数。View Code #include"iostream"using namespace std;int a[10000];int main(){ int t; int n; cin>>t; while(t--) { cin>>n; a[1]=2; for(int i=2;i<=n;i++) a[i]=a[i-1]+6*(i-1); cout<<a[n]<<endl; } return 0;} 阅读全文
posted @ 2011-04-22 19:01 聊聊IT那些事 阅读(312) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1406需要注意的地方:num1和num2的大小关系不确定。View Code #include"iostream"using namespace std;int v[10000];void Init(){ int i,j; memset(v,0,sizeof(v)); for(i=2; i<10000; i++) { int sum=0; for(j=1;j<=i/2;j++) { if(i%j==0) sum+=j; } if(sum==i) { v[i]=1; } }}in 阅读全文
posted @ 2011-04-22 18:33 聊聊IT那些事 阅读(269) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2054很烦的题~~View Code #include"iostream"#include"string"using namespace std;int i,j,L1,L2;char a[20000],b[20000];int main(){ while(scanf("%s %s",&a,&b)!=EOF) { if(a[0]=='-'&&b[0]=='-'||a[0]!='-& 阅读全文
posted @ 2011-04-22 18:15 聊聊IT那些事 阅读(669) 评论(0) 推荐(0) 编辑
摘要: View Code #include"iostream"#define M 20000#include"algorithm"using namespace std;int c[M];int main(){ int n,m; int a,b; int i,j; while(cin>>n>>m) { int k=0; for(i=0;i<n;i++) { cin>>a; c[k++]=a;} for(i=0;i<m;i++) { cin>>b; c[k++]=b;} sort(c,c+k); for 阅读全文
posted @ 2011-04-22 18:14 聊聊IT那些事 阅读(162) 评论(0) 推荐(0) 编辑
摘要: View Code #include"iostream"using namespace std;int main(){ char ch[1000]; char a[1000][100]; int i,j; int used[1000]; while(gets(ch)) { if(strcmp(ch,"#")==0) break; int L=strlen(ch); int start=0,end=L-1; for(i=0;i<L;i++) if(ch[i]!=' ') {start=i; break;} for(i=L-1;i> 阅读全文
posted @ 2011-04-22 16:57 聊聊IT那些事 阅读(454) 评论(0) 推荐(0) 编辑
摘要: #include"iostream"using namespace std;char s[100];char S[100],E[100];int i=0,j;int used[1000];int sign=0,mark=0;void dfs(int x){ if(E[x]=='m') { cout<<"Yes."<<endl; sign=1; mark=1; } //sign标志已经找到尾“m”,mark表示找到'm'的情况:如果找到则mark=1,否则mark=0; else { for(int 阅读全文
posted @ 2011-04-22 12:17 聊聊IT那些事 阅读(633) 评论(0) 推荐(0) 编辑