![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 78
fengfei1989
小弟大三,向各位前辈学习!
展开
-
JOJ1064: Caeser Comes Back
<br />原题地址:http://acm.jlu.edu.cn/joj/showproblem.php?pid=1064<br />很简单的密码问题。<br />#include <iostream><br />#include <string><br /><br />using namespace std;<br />void encode(string & str)<br />{<br /> int i,j,len = str.length();<br /> for(i=0;i<len;i原创 2010-07-04 12:41:00 · 249 阅读 · 0 评论 -
不用sizeof求计算机是32位还是64位
昨天和十多位同学到哈工大去参加某著名互联网公司的实习生笔试,其中有一道题是“不用sizeof求计算机是32位还是64位”。我想的解法是使用位运算来实现,具体原理是将int型的数字1向左移动,直到最右边的bit位1移动到最左边为止。代码如下:#includeint main(int argc,const char **argv){ int shiftTimes原创 2010-05-16 20:41:00 · 394 阅读 · 0 评论 -
判断一个数是否是2的阶次方数
对于一个正整数d,如果(d-1) & d 的结果是0,那么d就是2的阶次。 package com.fengfei.test;import java.io.BufferedReader;import java.io.InputStreamReader;/** * 判断一个数是否是2的阶次方数 * 如果(d-1) & d 的结果是0,那么d就是2的阶次 * @author fen原创 2010-05-18 15:16:00 · 500 阅读 · 0 评论 -
JOJ1011: If only I had a Venn diagram
<br />原题地址:http://acm.jlu.edu.cn/joj/showproblem.php?pid=1011<br />将输入的两个数组放在一起排序,排序后如果前后两个数相同就不须打印<br />#include <iostream> <br />#include <algorithm> <br />using namespace std; <br /> <br />int comp(const void* a,const void*b)<br />{<br /> int * aa原创 2010-07-02 22:01:00 · 268 阅读 · 0 评论 -
JOJ 1003: Channel Allocation
<br />原题地址http://acm.jlu.edu.cn/joj/showproblem.php?pid=1003<br />这是一个有关图的m着色的问题,应用到了回溯算法。<br />#include <stdio.h><br /> #include <memory.h><br /><br /> #define N 26<br /><br /> int a[N+1][N+1];//邻接矩阵 <br /> int x[N+1]; //各个顶点的图色 <br /> int flag;//是否符原创 2010-06-30 23:09:00 · 326 阅读 · 0 评论 -
JOJ1007: Triangles
<br />原题地址http://acm.jlu.edu.cn/joj/showproblem.php?pid=1007<br />using namespace std;<br /><br /> int main()<br /> {<br /> int n;<br /> while(cin>>n && n)<br /> {<br /> int f=0,h=0;<br /> for(int i=1;;++i)<br />原创 2010-06-30 23:24:00 · 338 阅读 · 0 评论 -
JOJ 1085: I Think I Need a Houseboat
<br />原题地址:http://acm.jlu.edu.cn/joj/showproblem.php?pid=1085<br />很简单的数学问题。<br />#include <iostream><br />using namespace std;<br />const double PI = 3.1415;<br />int main()<br />{<br /> int i,n,years;<br /> double a,b,rs;<br /> cin>>n;<br />原创 2010-07-04 23:47:00 · 284 阅读 · 0 评论 -
JOJ1012: Diophantus was a Greek, not a geek.
<br />原来题位置:http://acm.jlu.edu.cn/joj/showproblem.php?pid=1012<br />这是简单的计算最大公约数的Eclude算法<br />#include <stdio.h><br /><br />int gcd(int a,int b)<br />{<br /> int r;<br /> while(b!=0)<br /> {<br /> r = a%b;<br /> a = b;<br />原创 2010-07-02 20:58:00 · 219 阅读 · 0 评论 -
JOJ1020: u Calculate e
<br />源题地址:http://acm.jlu.edu.cn/joj/showproblem.php?pid=1020<br />很简单的题,练练手<br />#include <stdio.h><br />#include <stdlib.h><br />#include <memory.h><br /><br />double exe()<br />{<br /> int i;<br /> double j = 1.0/(1*2);<br /> double val = 2.5;<原创 2010-07-02 21:18:00 · 184 阅读 · 0 评论 -
JOJ1013: Polynomial Multiplication
原题地址连接:http://acm.jlu.edu.cn/joj/showproblem.php?pid=1013多项式相乘算法很简单,但是输出要求很苛刻,比如空白,换行等#include #include #include #define N 20int result[3*N];int left[N];int right[N];原创 2010-07-16 16:46:00 · 273 阅读 · 0 评论