空格

  1. Markdown不识别半角空格,当需要空格时,按shift+Space,然后再按空格键即可。
  2. 可直接输入HTML entities中的空格占位符:
    • en space, U+2002 ISOpub
       半方大的空白  
    • em space, U+2003 ISOpub
       全方大的空白  
    • no-break space = non-breaking space, U+00A0 ISOnum
       不断行的空白格 或 
      Read more »

使用Jetpack,连接wordpress.com时出现register_http_request_failed错误。
本文环境:vps+linux+nginx。

解决方法:

修改php.ini文件中max_execution_time
1. 寻找php.ini文件
linux下使用命令

1
sudo find / -name 'php.ini'

本文中php.ini位置为/usr/local/php/etc/php.ini
2. 将php.ini文件中max_execution_time的值修改为300.然后重启vps。连接jetpack后记得修改回去。

题目描述

给定两个正整数,计算这两个数的最小公倍数。

输入

输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数。

输出

对于每个测试用例,给出这两个数的最小公倍数,每个实例输出一行。

样例输入:

10 14

样例输出:

70

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
int gcd(int a,int b)
{
while(b!=0)
{
int t=a%b;
a=b;
b=t;
}
return a;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("E:\\jsj\\cprojects\\docs\\in.txt","r",stdin);
//freopen("E:\\jsj\\cprojects\\docs\\mout.txt","w",stdout);
#endif
int a,b;
while(~scanf("%d%d",&a,&b))
{
printf("%d\n",a*b/gcd(a,b));
}
return 0;
}

Total Accepted: 100793 Total Submissions: 429248 Difficulty: Easy
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321

Have you thought about this?Here are some good questions to ask before coding. Bonus points for you if you have already thought through this! If the integer’s last digit is 0, what should the output be? ie, cases such as 10, 100. Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reverse of 1000000003 overflows. How should you handle such cases? For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows. Update (2014-11-10): Test cases had been added to test the overflow behavior.

Tags
Math

Hide Similar Problems
(E) String to Integer (atoi)

Discuss
来源: https://leetcode.com/problems/reverse-integer/

代码(Accepted):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Solution {
public:
int reverse(int x) {
int ret = 0;
while(x!=0){
if(ret>INT_MAX/10||ret<INT_MIN/10){
return 0;
}
ret = ret*10 + x%10;
x = x/10;
}
return ret;
}
};
 我感觉最准确的应该是下面这个
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Solution {
public:
int reverse(int x) {
int ret = 0;
while(x!=0){
if(ret>INT_MAX/10-x%10/10||ret<INT_MIN/10-x%10/10){
return 0;
}
ret = ret*10 + x%10;
x = x/10;
}
return ret;
}
};

Solution:

To check for overflow/underflow, we could check if ret > 214748364 or ret < –214748364 before multiplying by 10. On the other hand, we do not need to check if ret == 214748364, why?

相关链接:

http://blog.csdn.net/nomasp/article/details/48675979

int型整数的最小值和最大值 http://bbs.csdn.net/topics/340223320

本题解析:

本题一定要把判断加在while循环之中,并且要在乘10之前判断是否超出范围。

遗留问题:

1.两段代码更精确的感觉应该是下面那个。
2.运行时间8ms,比较长,有待优化。(your runtime beats 24.74% of cpp submissions.)

相关知识点:

  1. 整数最大值和最小值
    INT_MAX和INT_MIN定义在limits.h中。
    INT_MAX #define INT_MAX 2147483647
    INT_MIN #define INT_MIN (-2147483647 – 1)
    注意:其中INT_MIN最小值没有写成-2147483647,是因为-2147483648对于编译器而言是个表达式,而2147483648对于32-bit整数是无法表示的,所以经过这个表达式的结果是未定义的。在GCC上直接写-2147483648后,编译器给出了警告,说结果是unsigned。可参考 INT_MIN.
    也可用以下写法(推荐):
    1
    2
    #define MAX_INT ((unsigned)(-1) >> 1)
    #define MIN_INT (int)(MAX_INT + 1)

时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4894 解决:2183

题目描述:

判断两序列是否为同一二叉搜索树序列

输入:

开始一个数n,(1<=n<=20) 表示有n个需要判断,n= 0 的时候输入结束。
接下去一行是一个序列,序列长度小于10,包含(0~9)的数字,没有重复数字,根据这个序列可以构造出一颗二叉搜索树。
接下去的n行有n个序列,每个序列格式跟第一个序列一样,请判断这两个序列是否能组成同一颗二叉搜索树。

输出:

如果序列相同则输出YES,否则输出NO
样例输入:

2
567432
543267
576342
0

样例输出:

YES
NO

来源:
2010年浙江大学计算机及软件工程研究生机试真题
答疑:
解题遇到问题?分享解题心得?讨论本题请访问:http://t.jobdu.com/thread-7733-1-1.html
来源: http://ac.jobdu.com/problem.php?pid=1009

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
对输入数字序列构建二叉排序树,并对它们进行前序和中序遍历,
依次比较两次遍历结果是否相同,若相同则说明两棵二叉排序树
相同,否则不同
*/
#include<stdio.h>
#include<string.h>
typedef struct Node
{
struct Node *lchild;
struct Node *rchild;
int c;
}Node;
Node bTree[110];
int loc;
char str1[25],str2[25];
int size1,size2;
char *str;
int *size;
void preOrder(Node *T)
{
if(T!=NULL)
{
str[(*size)++]=T->c+'0';
preOrder(T->lchild);
preOrder(T->rchild);
}
}
void inOrder(Node *T)
{
if(T!=NULL)
{
inOrder(T->lchild);
str[(*size)++]=T->c+'0';
inOrder(T->rchild);
}
}
struct Node* insert(Node* T,int x)
{
if(!T)
{
T=&bTree[loc++];
T->c=x;
T->lchild=T->rchild=NULL;
return T;
}
else if(x<T->c) T->lchild=insert(T->lchild,x);
else if(x>T->c) T->rchild=insert(T->rchild,x);
return T;
};
int main()
{
#ifndef ONLINE_JUDGE
freopen("E:\jsj\cprojects\docs\in.txt","r",stdin);
//freopen("E:\jsj\cprojects\docs\mout.txt","w",stdout);
#endif
int n,i;
char tmp[12];
while(~scanf("%d",&n)&&n!=0)
{
Node *T=NULL;
scanf("%s",tmp);
for(loc=i=0;tmp[i]!=0;++i)
{
T=insert(T,tmp[i]-'0');
}
size1=0;
str=str1;
size=&size1;
preOrder(T);
inOrder(T);
str1[size1]=0;
while(n--!=0)
{
scanf("%s",tmp);
Node *T2=NULL;
for(i=0;tmp[i]!=0;++i)
{
T2=insert(T2,tmp[i]-'0');
}
size2=0;
str=str2;
size=&size2;
preOrder(T2);
inOrder(T2);
str2[size2]=0;
puts(strcmp(str1,str2)==0?"YES":"NO");
}
}
return 0;
}

时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6479 解决:2176

题目描述:

输入一个整数n(2<=n<=10000),要求输出所有从1到这个整数之间(不包括1和这个整数)个位为1的素数,如果没有则输出-1。
输入:
输入有多组数据。
每组一行,输入n。
输出:
输出所有从1到这个整数之间(不包括1和这个整数)个位为1的素数(素数之间用空格隔开,最后一个素数后面没有空格),如果没有则输出-1。
样例输入:

100

样例输出:

11 31 41 61 71

来源:
2008年北京航空航天大学计算机研究生机试真题
答疑:
解题遇到问题?分享解题心得?讨论本题请访问:http://t.jobdu.com/thread-7886-1-1.html
来源: http://ac.jobdu.com/problem.php?pid=1163

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
int prime[10000];
int primeSize;
char mark[10001];
void init()
{
int i=1;
for(; i<=10000; ++i) mark[i]=0;
primeSize=0;
for(i=2; i<=10000; ++i)
{
if(mark[i]) continue;
prime[primeSize++]=i;
int j=i*i; //注意:i*k,而当k<i时其所有倍数已经被标记完了,所以从i*i开始
for(; j<=10000; j+=i) mark[j]=1;
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("E:\jsj\cprojects\docs\in.txt","r",stdin);
//freopen("E:\jsj\cprojects\docs\mout.txt","w",stdout);
#endif
init();
int n,i;
while(~scanf("%d",&n))
{
char isOutput=0;
for(i=0; i<primeSize; ++i)
{
if(prime[i]<n&&prime[i]%10==1)
{
if(isOutput==0)
{
isOutput=1;
printf("%d",prime[i]);
}
else printf(" %d",prime[i]);
}
}
if(isOutput==0) printf("-1n");
else printf("n");
}
return 0;
}

时间限制:1 秒 内存限制:32 兆

题目描述:

求正整数N(N>1)的质因数的个数。
相同的质因数需要重复计算。如120=22235,共有5个质因数。

输入:

可能有多组测试数据,每组测试数据的输入是一个正整数N,(1<N<10^9)。

输出:

对于每组数据,输出N的质因数的个数。

样例输入:

120

样例输出:

5

提示:

注意:1不是N的质因数;若N为质数,N是N的质因数。

来源:2007年清华大学计算机研究生机试真题
答疑:解题遇到问题?分享解题心得?讨论本题请访问:http://t.jobdu.com/thread-7930-1-1.html
来源: http://ac.jobdu.com/problem.php?pid=1207

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
int prime[10000];
int primeSize;
char mark[10001];
void init()
{
int i=1;
for(; i<=10000; ++i) mark[i]=0;
primeSize=0;
for(i=2; i<=10000; ++i)
{
if(mark[i]) continue;
prime[primeSize++]=i;
int j=i*i; //注意:i*k,而当k<i时其所有倍数已经被标记完了,所以从i*i开始
for(; j<=10000; j+=i) mark[j]=1;
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("E:\\jsj\\cprojects\\docs\\in.txt","r",stdin);
//freopen("E:\jsj\cprojects\docs\mout.txt","w",stdout);
#endif
init();
int n,i;
while(~scanf("%d",&n))
{
//int ansPrime[30];
int ansSize=0;
int ansNum[30];
for(i=0;i<primeSize;++i)
{
if(n%prime[i]==0)
{
//ansPrime[ansSize]=prime[i];
ansNum[ansSize]=0;
while(n%prime[i]==0)
{
ansNum[ansSize]++;
n/=prime[i];
}
ansSize++;
if(n==1) break;
}
}
if(n!=1)
{
//ansPrime[ansSize]=n;
ansNum[ansSize++]=1;
}
int ans=0;
for(i=0;i<ansSize;++i) ans+=ansNum[i];
printf("%dn",ans);
}
return 0;
}

Bitvise SSH Client is an SSH and SFTP client for Windows. It is developed and supported professionally by Bitvise. The SSH Client is robust, easy to install, easy to use, and supports all features supported by PuTTY, as well as the following:

  • graphical SFTP file transfer;
  • single-click Remote Desktop tunneling;
  • auto-reconnecting capability;
  • dynamic port forwarding through an integrated proxy;
  • an FTP-to-SFTP protocol bridge.

Bitvise SSH Client is free for personal use, as well as for individual commercial use inside organizations. You can download Bitvise SSH Client here.

20150705153604
20150705153727
20150705153639

Bitvise SSH Client可以同时打开sftp和ssh.并且对个人免费,仅用于windows.

0%