IT民工
加油!
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 29 下一页
摘要: 题意是找到一个最小的数,使得这个数的各位的乘积等于n,首先小于10的数肯定是他本身了。这里不得不拜服knowledgetime大神,从9到2找到这8个数字作为n的因子可以出现几次,然后从小到大依次输出。#include<cstdio>#include<cstdlib>#include<cstring>int main(){ int a[10]; int n, T; scanf( "%d", &T); while( T --) { scanf( "%d", &n); if( n < 10){ pri 阅读全文
posted @ 2012-02-01 18:45 找回失去的 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 因为最终都会满足每个人的要求。所以我们可以当作每个居民与他的邻居进行交易,将每次的交易额计算出来相加即可。#include<cstdio>#include<cstdlib>#define MAXN 100010int a[MAXN];long long min, w;int n;int main(){ while( scanf( "%d", &n), n) { for( int i = 0; i < n; i ++) scanf( "%d", &a[i]); min = w = 0; for( int i = 阅读全文
posted @ 2012-02-01 17:45 找回失去的 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 一道解方程的题,给定区间0到1.如果f(0) * f(1)大于零代表这个区间内所有的x对应的y值都在y轴的一侧,也就是无解。然后用二分的方法解方程。注意变量都要定义成double。#include<cstdio>#include<cstdlib>#include<cmath>const double T = 10e-8;double p, q, r, s, t, u;double res( double x){ return p*exp(-x) + q*sin(x) + r*cos(x) + s*tan(x) + t*x*x + u;}int main(){ 阅读全文
posted @ 2012-02-01 17:03 找回失去的 阅读(273) 评论(0) 推荐(0) 编辑
摘要: 一个整数n,求它的一个序列,这个序列的要求是其中任何一个子序列都不能是等差序列。枚举必然超时,然后想了半个小时没有任何想法,就参考了七里 大神的思路,用分治法将序列中处于奇偶位置的数字分组,开始分出来的是等差2的序列,然后再在奇偶序列中分组,最终得出的序列就是符合要求的序列中的一个。暂时没有更好的想法。#include<cstdio>#include<cstring>#include<cstdlib>#define MAXN 10010int a[MAXN], b[MAXN];int n;void dvide( int x, int y){ int i, j 阅读全文
posted @ 2012-02-01 14:09 找回失去的 阅读(462) 评论(0) 推荐(0) 编辑
摘要: 题目大意:两个字符串,一个是s1<s2>s3<s4>s5,另一个是s'...,输出s1s2s3s4s5和s's4s3s2s5.开始一下居然没有想法,后面模拟了下,将s2,s3,s4,s5单独拿出来分别存入a1,a2,a3,a4四个字符串中,然后按题目要求即可!#include<cstdio>#include<cstring>#include<cstdlib>const int MAXD = 105;char s1[MAXD], s2[MAXD];char a1[MAXD], a2[MAXD], a3[MAXD], a4 阅读全文
posted @ 2012-01-28 17:16 找回失去的 阅读(351) 评论(0) 推荐(0) 编辑
摘要: 一道字符串模拟题,每行对应的是字符的ASC码参考了syhd142的写法,他的exp数组用得比较精髓。#include<cstdio>#include<cstdlib>#include<cstring>const int exp[] = { 0, 128, 64, 32, 16, 8, 0, 4, 2, 1};char data[20];int main(){ while( gets( data) ) { int ans = 0; int len = strlen( data); if( data[0] != '|' ) continue; . 阅读全文
posted @ 2012-01-28 17:15 找回失去的 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 判断一组code当中有没有其中一个是另一个的前缀,如果有的话就不是immediately decodable ,反正则是。我们首先要将每组字符串单独取出来进行排序,按照由短到长,相同长度按字典序排序。排序之后用靠前的字符串与靠后的比较。#include<cstdio>#include<cstring>#include<cstdlib>#define MAXN 20char co[MAXN][15], str[15];int cmp( const void *_a, const void *_b){ char *a = ( char *)_a; char *b 阅读全文
posted @ 2012-01-28 17:14 找回失去的 阅读(405) 评论(0) 推荐(0) 编辑
摘要: 这道题是要找到字符串在字符矩阵里的位置,并输出其头字母的坐标。我们先找到首字母的位置,然后按照八个方向当中的一个搜索,如果能找到完整的字符串,就输出坐标。与DFS每个点按照八个方向搜索不同的是,这里只是按照一个方向一个方向地搜索。所以搜索函数也稍有不同。#include<cstdio>#include<cstring>#include<cstdlib>#include<ctype.h>#define MAXN 60int cas, m, n, q;int x, y;char r[MAXN][MAXN];const int dx[] = { 1, 阅读全文
posted @ 2012-01-28 17:13 找回失去的 阅读(506) 评论(0) 推荐(0) 编辑
摘要: 将单词转换成小写后按照字典序输出。#include<cstdio>#include<cstring>#include<cstdlib>#include<ctype.h>char word[100010][50] = {'\0'};int cmp( const void *_p, const void *_q){ char *p = ( char *)_p; char *q = ( char *)_q; return strcmp( p, q);}int main(){ char ch; int n = 0, len = 0; wh 阅读全文
posted @ 2012-01-28 17:12 找回失去的 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 八皇后问题的变形,这道题不是要我们求有多少种方法,而是在给定价值的棋盘格子放皇后,使得皇后放置的位置的总价值最大。参考了白书的126页的代码,用vis数组表示已经放置的皇后占据了哪些列以及哪些主、副对角线。然后将放置皇后,改成加上该格子的值。不能忘了将vis初始化false和最后的输出的%5d。#include<cstdio>#include<cstdlib>#include<cstring>#define MAXN 10const int N = 8;int val[MAXN][MAXN], max, ans;bool vis[MAXN][MAXN];vo 阅读全文
posted @ 2012-01-16 22:58 找回失去的 阅读(477) 评论(0) 推荐(1) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 29 下一页