上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 26 下一页
摘要: 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那些事 阅读(273) 评论(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那些事 阅读(675) 评论(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那些事 阅读(164) 评论(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那些事 阅读(457) 评论(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那些事 阅读(640) 评论(0) 推荐(0)
摘要: 水题一道,注意闰年和平年的判断。View Code #include"iostream"using namespace std;int main(){ int y,m,d; while(scanf("%d/%d/%d",&y,&m,&d)!=EOF) { int sum=0,i; for(i=1;i<m;i++) { switch(i) { case 1: sum+=31; break; case 2: { if(y%4==0&&y%100||y%400==0) { sum+=29; } else sum+= 阅读全文
posted @ 2011-04-21 16:04 聊聊IT那些事 阅读(523) 评论(0) 推荐(0)
摘要: View Code //Problem 2013 A short problem /*Accept: 158 Submit: 452Time Limit: 1000 mSec Memory Limit : 32768 KB Problem DescriptionThe description of this problem is very short. Now give you a string(length N), and ask you the max sum of the substring which the length can't small than M.InputThe 阅读全文
posted @ 2011-04-21 14:59 聊聊IT那些事 阅读(234) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1290同切西瓜问题一样 阅读全文
posted @ 2011-04-20 18:00 聊聊IT那些事 阅读(277) 评论(0) 推荐(0)
摘要: 摘自:http://blog.sina.com.cn/s/blog_59e67e2c0100a7yx.html需要慢慢注墨。。。。首先引用下leemars的报告:这道题要求N!的最后一个非0数字是多少,如果用一般作法,先统计2和5的个数,然后补乘2,得到的将是TLE。所以还需要再做简化:为了把0去掉,我们把所有的因数2和5都提出来,放到最后再处理。N!中的N个相乘的数可以分成两堆:奇数和偶数。偶数相乘可以写成(2^M)*(M!),M=N DIV 2。M!可以递归处理,因此现在只需讨论奇数相乘。考虑1*3*5*7*9*11*13*15*17* ... *N(如果N为偶数则是N-1),这里面是5的 阅读全文
posted @ 2011-04-20 17:56 聊聊IT那些事 阅读(1092) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1568看了半天,没思路,摘了一位dn的,学习了!View Code 先看对数的性质,loga(b^c)=c*loga(b),loga(b*c)=loga(b)+loga(c);假设给出一个数10234432,那么log10(10234432)=log10(1.0234432*10^7)=log10(1.0234432)+7;log10(1.0234432)就是log10(10234432)的小数部分.log10(1.0234432)=0.01006374410^0.010063744=1.023443198那 阅读全文
posted @ 2011-04-20 17:11 聊聊IT那些事 阅读(390) 评论(0) 推荐(0)
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 26 下一页