![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM
yyliunianyy
这个作者很懒,什么都没留下…
展开
-
1997: Simple Problem I
很水的一道题,只需要把大写字母变成小写字母,把小写字母变成大写字母,代码只有几行,被蒙了! AC代码: #include int main(){ char ch; while(scanf("%c",&ch)!=EOF){ if(ch>=a&&ch printf("%c",ch-32); else if(ch>=原创 2010-03-24 20:57:00 · 227 阅读 · 0 评论 -
joj 1989 Vampire Numbers
<br />http://acm.jlu.edu.cn/joj/showproblem.php?pid=1989<br /> <br />应该是到水题 只要列举出所有的情况 共12种 就行了 不会超时 而且是0MS 做出来之后发现只有几个数 可以直接打印出来 如第二段代码<br /> <br /> <br />#include<stdio.h>int main(){ int a[4]; int i,j,n,k,temp,flag; for(i=1000;i<10000;i++){ n=原创 2010-09-10 19:51:00 · 312 阅读 · 0 评论 -
joj 2619 Magic Train Station
<br />http://acm.jlu.edu.cn/joj/showproblem.php?pid=2619<br /><br />注意:Hint: The name can be as long as 1000 character & may contains space.<br /><br />没看好名字有一千位 所有wa了好多次<br /> <br />#include<stdio.h>int main(){ int n,t1[1001],t2[1001],i,j,flag,r; ch原创 2010-09-14 20:02:00 · 314 阅读 · 0 评论 -
joj 1387 CD
http://acm.jlu.edu.cn/joj/showproblem.php?pid=1387动态规划问题,用DFS也应该能做,不过应该比较费时#include#includeint cmp(const void*a,const void*b){ return *(int *)b-*(int *)a;}#define N 101int a[N],used[N];int main(){ int i,j,k,size,n,max,sum; while(scanf("%d原创 2010-09-08 17:00:00 · 307 阅读 · 0 评论 -
joj 2652 数组操作
<br />http://acm.jlu.edu.cn/joj/showproblem.php?pid=2652<br /> <br />如果用数组模拟指针会更省时<br /> <br />#include<stdio.h>#include<memory.h>#define N 1000030int a[N];int main(){ int i,j,t,n,m,flag; char ch; while(scanf("%d%d",&n,&m)!=EOF,n){ memset(原创 2010-09-17 19:02:00 · 381 阅读 · 0 评论 -
joj 1167 How Many Eggs Do I Have?
http://acm.jlu.edu.cn/joj/showproblem.php?pid=1167>求一次同余式组中国剩余定理定义 根据定义可以写出代码设m1,m2,...mn是两两互素的正整数,则x≡bi mod mi(i=1,2,...n)在模m1m2m3...mn下有唯一解。这M=m1m2....mn,Mj=M/mj,且Mjyj≡1 mod mj(j=1,2,...n),则x=b1M1y1+b2M2y2+...+bnMnyn mod m1m2m3...mn即是符合条件的解。#includeint原创 2010-09-08 20:39:00 · 332 阅读 · 0 评论 -
joj 1595 Combinations
<br />http://acm.jlu.edu.cn/joj/showproblem.php?pid=1595<br /> <br />此题是求组合数问题,即求C(n,m)问题,根据组合公式C(n,m)=C(n-1,m)+C(n-1,m-1)可以将此题转化成大数加法<br />#include<stdio.h>#include<string.h>void add(char a[],char b[],char c[]){ int dig=0,temp,i; for(i=0;a[i]!='/0原创 2010-10-27 19:15:00 · 310 阅读 · 0 评论 -
joj 2526: medic
<br />http://acm.jlu.edu.cn/joj/showproblem.php?pid=2526<br />最基本的0-1背包问题 <br /><br />动态规划 2维解法 (因为数组开错 导致wa 所以贴出来警示自己)<br /> <br />#include<stdio.h>#include<iostream>using namespace std;#define T 1005#define M 105int f[M][T];int max(int a,int原创 2011-03-01 13:54:00 · 388 阅读 · 0 评论 -
杭电OJ 1003 最大子序列(分治法)Max Sum
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1003需要注意的问题:1、需要设置最小值,题目中说序列中的值在-1000到1000之间,因此在设置初始值时不能使用02、为了获取第一个最大自序列,解的优先级左侧>过中点>右侧#include#define MAX_SIZE 100000#define MIN - 10000in原创 2016-07-15 14:39:11 · 708 阅读 · 0 评论 -
poj 3984 迷宫问题
此题用BFS输出最短路径,此题的测试数据为一组http://poj.org/problem?id=3984#include#includeusing namespace std;int a[5][5];int b[5][5];queuex;queuey;void bfs(int i,int j){ int s,t,ii; int dx[4]={1,-1,0,0}; int dy[4]={0,0,1,-1}; while(!x.empty()) x.pop();原创 2011-01-18 15:21:00 · 825 阅读 · 0 评论 -
poj 1002 487-3279
<br />http://acm.pku.edu.cn/JudgeOnline/problem?id=1002<br /> <br />自己琢磨出用qsort排字符串数组,虽然时间很多860ms 但是很有成就感<br /> <br />#include<stdio.h>#include<string.h>#include<stdlib.h>int cmp(const void*a,const void*b){ return strcmp((char*)a,(char *)b);}in原创 2010-09-14 21:32:00 · 237 阅读 · 0 评论 -
POJ 1423 Big Number
<br />要知道一个数字的位数是多少,我们可以用log10函数求得。例如,对于一个数,N=10,10!=3628800,而log10(3628800)=6.559763033,那么只要将这个数向上取整,就是7,就是10!的位数<br />有两种方法求n!<br /><br />第一种 strling公式 用时为0ms<br /><br /><br />#include<stdio.h>#include<math.h>#define e 2.7182818284590452354#define原创 2010-09-13 16:01:00 · 295 阅读 · 0 评论 -
Poj 1426 Find The Multiple
<br />http://acm.pku.edu.cn/JudgeOnline/problem?id=1426<br /> <br />刚刚学写BFS 比DFS容易些 这题比较简单 只要找到任意的一个0、1组合可以整除所给的数就行 用int64可以做,注意99、198这两个数据 时间比较长 单独列出来可以节省时间 如果不单独考虑 用C++就超时了 但G++可以过 不过时间要200多MS <br />这个程序用了32MS 不错了<br /> <br />#include<stdio.h>#include<原创 2010-08-09 12:41:00 · 390 阅读 · 1 评论 -
joj 2284 W-LINE
http://acm.jlu.edu.cn/joj/showproblem.php?pid=2284题意就是求这样的W型折线能把平面最多分成几个部分?一看到这种题目,没得说,就是去找它的递推公式。这和直线分平面,折线分平面,三角形分平面,还有圆分平面,平面分空间都是一类题。从我推这些题中得出了一个结论,要想推出它们的关系就必须找到它们的共同点,和呈线性变化的量,以及一些不变量,变化的量与不变量的关系等,如果找到了那么问题就简单了。1.直线分平面:揪住要得到最多的分块,就要让它们的直线尽可能多的相交,每多一个原创 2010-09-10 20:01:00 · 373 阅读 · 0 评论 -
joj 2677 The Natural Series
<br /> http://acm.jlu.edu.cn/joj/showproblem.php?pid=2677&contestid=165<br /> <br /><br /><br />一道简单的DFS搜索题,不过要注意第n-1个、第n个 和第1个也应该满足题中的规律,我没审好题,结果WA,调试了一下午,不过时间用了0.02s <br /> <br /> <br />#include<stdio.h>int a[20],visited[20];int n,m;void output(in原创 2010-07-17 19:11:00 · 278 阅读 · 0 评论 -
2013: Sum
#include#includeint cmp1(const void *a,const void *b){ return *(int*)a-*(int*)b;}int main(){ int a[1000002],n,x; int i,j,k,lower,upper,flag; while(scanf("%d%d",&n,&x)!=EOF){ for(i=0;i sca原创 2010-03-24 23:16:00 · 181 阅读 · 0 评论 -
1897: WERTYU
#include int main(){ char list[]="`1234567890-=~!@#$%^&*()_+QWERTYUIOP[]//ASDFGHJKL;ZXCVBNM,./"; char a; while(scanf("%c",&a)!=EOF){ for(int i=0;list[i];i++) if(list[i]==a)a=list[i-1]; printf("%c原创 2010-03-26 23:01:00 · 204 阅读 · 0 评论 -
1175: The Binomial Function
动态规划问题 注意输出格式 #include#include#define N 31int used[N][N];int Binom(int n,int m){ if(n==0||n==m||m==0) return 1; else{ if(used[n][m]){ return used[n][m]; } else { used[n][m]=Binom(n-1,m)+Bi原创 2010-04-11 20:47:00 · 372 阅读 · 0 评论 -
1029: Niven Numbers
让我疯掉的一道水题 注意审题 第一行的1是指数据的个数 每个数据是以0为截止的 #include#includeint main(){int d,sum,sum1,j,n;int i;char s[500];scanf("%d",&n);while(n--){ while(scanf("%d",&d)!=EOF){ if(d==0) b原创 2010-04-14 23:13:00 · 344 阅读 · 0 评论 -
2473 Bivariate recursion function
数组used初始化时值为-1(负数就行),因为有值等于0的情况 #include#include#include#define N 101int used[N][N];int f(int m,int n){ if(n==0) return m; if(m==0) return n; if(used[m][n]!=-1) return used[m][原创 2010-04-16 20:57:00 · 224 阅读 · 0 评论 -
2098: All in All
#include#includeint main(){ int i,j,p,q; char s[100000],t[100000]; while(scanf("%s%s",s,t)!=EOF){ i=0; j=0; p=strlen(s); q=strlen(t); while(i<p&&j<q) if(s[i]!=t[j]) j原创 2010-04-16 21:22:00 · 191 阅读 · 0 评论 -
2616 供热管道优化
#include#include#includeint cmp1(const void *a,const void *b){ return *(int*)a-*(int*)b;}int main(){ int x[1600],y[1600]; int t,sum,n,i; while(scanf("%d",&n)!=EOF){ if(n==0) r原创 2010-04-24 17:04:00 · 323 阅读 · 0 评论 -
2618 混乱的扑克牌
#includeint main(){ int a[501],i,j,k,n,count,flag; while(scanf("%d%d",&n,&k)!=EOF){ if(n==0&&k==0) return 0; else{ flag=0; for(i=0;i<n;i++) scanf("%d",&(a[i])); count=原创 2010-04-24 17:03:00 · 292 阅读 · 0 评论 -
2255: Bus Tickets
票价是随机的 #includeint main(){ int t; int allpaid; int paid,epaid; int i; scanf("%d",&t); for(i=0;i<t;i++){ scanf("%d",&paid); allpaid=0; for(int j=0;j<paid;j++){ scanf("%d原创 2010-04-25 19:37:00 · 246 阅读 · 0 评论 -
1198: Risk
Floyd算法#include#define inf 1000int main(){ int t=0,x,y,i,j,k,n,m; int a[30][30]; while(scanf("%d",&m)!=EOF){ t++; for(i=1;i<=20;i++) for(j=1;j<=20;j++) if(i==j) a[i]原创 2010-05-06 20:31:00 · 189 阅读 · 0 评论 -
1170: Wire Is So Expensive
最小生成树 Prim算法实现#include#define inf 10000int main(){ int c[22][22]; int used[22]; int closest[22]; int lowcost[22]; int ans,m,n,i,j,a1,b1,c1; scanf("%d",&m); for(int t=0;t<m;t++){原创 2010-05-07 15:26:00 · 246 阅读 · 0 评论 -
joj 1177 The 3n + 1 problem
<br />http://acm.jlu.edu.cn/joj/showproblem.php?pid=1177<br />超级水的一道题 注意i,j的大小顺序 就是因为没考虑到这点所以wa <br />#include<stdio.h>int f(int n){ int m=1; if(n==1) return m; while(n!=1){ if(n%2==0) n/=2; else n=3*n+1; m++; }原创 2010-07-16 16:57:00 · 278 阅读 · 0 评论 -
poj 1007 DNA Sorting
<br />http://acm.pku.edu.cn/JudgeOnline/problem?id=1007<br /> <br />用简单的冒泡排序 竟然用了0MS就AC了 只不过这题的 (in order of ``sortedness'', from ``most sorted'' to ``least sorted'')<br />说的是按照从大到小 但是竟然是按照逆序数从小到大排列的 最先考虑的是相同的字母的逆序数是不想加的但是结果WA 后来改了 AC了<br /> <br /> <br />原创 2010-07-17 11:19:00 · 219 阅读 · 0 评论