升级Ubuntu14.04

昨天把Ubuntu升到了14.04,遇到了一些问题,在此说明一下:

问题一:ibus输入发生严重问题!

问题描述:

用输入法打字时,我输入的时“cha”,但是在ibus的界面中显示的是:“cang [cha]”,貌似所有带“h”的音都会被替换成“ang”。

解决办法:

百度到的:ibus-daemon -drx

问题二:chromium主题问题

问题描述:

chromium顶端的关闭窗口和最大、最小化按钮去右边了……

解决办法:

在窗口顶端点击鼠标右键,选择“使用系统标题栏和边框”,之后最大化页面,就好了。

其他问题还在发现中……

CodingTrip-携程编程大赛(预赛第二场)

1001-剪刀石头布

Problem Description

现有M个人一起玩剪刀石头布,以1-M编号,每人出一种,出过不再改变,但是我们并不知道它到底是哪一种。 (其中石头赢剪刀,剪刀赢布,布赢石头,一样则平)
裁判用两种说法对这M个人所构成的输赢关系进行描述:
一:”1 A B”,表示第A个人和第B个人出的一样。
二:”2 A B”,表示第A个人赢第B个人。

HDU 2106

decimal system

Problem Description

As we know , we always use the decimal system in our common life, even using the computer. If we want to calculate the value that 3 plus 9, we just import 3 and 9.after calculation of computer, we will get the result of 12.
But after learning << The Principle Of Computer >>,we know that the computer will do the calculation as the following steps:
1 computer change the 3 into binary formality like 11;
2 computer change the 9 into binary formality like 1001;
3 computer plus the two number and get the result 1100;
4 computer change the result into decimal formality like 12;
5 computer export the result;
In the computer system there are other formalities to deal with the number such as hexadecimal. Now I will give several number with a kind of change method, for example, if I give you 1011(2), it means 1011 is a number in the binary system, and 123(10) means 123 if a number in the decimal system. Now I will give you some numbers with any kind of system, you guys should tell me the sum of the number in the decimal system.

Input

There will be several cases. The first line of each case contains one integers N, and N means there will be N numbers to import, then there will be N numbers at the next N lines, each line contains a number with such form : X1….Xn.(Y), and 0<=Xi< Y, 1< Y <=10. I promise you that the sum will not exceed the 100000000, and there will be at most 100 cases and the 0< N<=1000.

Output

There is only one line output case for each input case, which is the sum of all the number. The sum must be expressed using the decimal system.

Sample Input

3
1(2)
2(3)
3(4)

4
11(10)
11(2)
11(3)
11(4)

Sample Output

6
23

题解:

直接就是进制转换,但是不知道为什么用g++交就WA,用C交就AC……

源代码:

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>
#include<math.h>
int main()
{

int a,b,c,sum,n,i;
while(scanf("%d",&n)!=EOF)
{
sum=0;
while(n--)
{
scanf("%d(%d)",&a,&b);
i=0;
while(a>0)
{
c=a%10;
a/=10;
sum+=(int)pow(b,i)*c;
i++;
}
}
printf("%d\n",sum);
}
return 0;
}

HDU 1326-2088

Box of Bricks

Problem Description

Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. “Look, I’ve built a wall!”, he tells his older sister Alice. “Nah, you should make all stacks the same height. Then you would have a real wall.”, she retorts. After a little con- sideration, Bob sees that she is right. So he sets out to rearrange the bricks, one by one, such that all stacks are the same height afterwards. But since Bob is lazy he wants to do this with the minimum number of bricks moved. Can you help?

Input

The input consists of several data sets. Each set begins with a line containing the number n of stacks Bob has built. The next line contains n numbers, the heights hi of the n stacks. You may assume 1 <= n <= 50 and 1 <= hi <= 100.
The total number of bricks will be divisible by the number of stacks. Thus, it is always possible to rearrange the bricks such that all stacks have the same height.
The input is terminated by a set starting with n = 0. This set should not be processed.

Output

For each set, first print the number of the set, as shown in the sample output. Then print the line ``The minimum number of moves is k.’’, where k is the minimum number of bricks that have to be moved in order to make all the stacks the same height.
Output a blank line after each set.

Sample Input

6
5 2 4 1 7 5
0

Sample Output

Set #1
The minimum number of moves is 5.

题解:

注意空行和答案中的句号

源代码:

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
#include<stdio.h>
#include<stdlib.h>
int main()
{

int a,b,n,i,s[55],k=0;
while(scanf("%d",&n)!=EOF)
{
k++;
a=0;
if(n==0)
{
break;
}
printf("Set #%d\n",k);
for(i=1;i<=n;i++)
{
scanf("%d",&s[i]);
a+=s[i];
}
a/=n;
b=0;
for(i=1;i<=n;i++)
{
if(s[i]>a)
{
b=b+s[i]-a;
}
}
printf("The minimum number of moves is %d.\n\n",b);
}
return 0;
}

HDU 2104

hide handkerchief

Problem Description

The Children’s Day has passed for some days .Has you remembered something happened at your childhood? I remembered I often played a game called hide handkerchief with my friends.
Now I introduce the game to you. Suppose there are N people played the game ,who sit on the ground forming a circle ,everyone owns a box behind them .Also there is a beautiful handkerchief hid in a box which is one of the boxes .
Then Haha(a friend of mine) is called to find the handkerchief. But he has a strange habit. Each time he will search the next box which is separated by M-1 boxes from the current box. For example, there are three boxes named A,B,C, and now Haha is at place of A. now he decide the M if equal to 2, so he will search A first, then he will search the C box, for C is separated by 2-1 = 1 box B from the current box A . Then he will search the box B ,then he will search the box A.
So after three times he establishes that he can find the beautiful handkerchief. Now I will give you N and M, can you tell me that Haha is able to find the handkerchief or not. If he can, you should tell me “YES”, else tell me “POOR Haha”.

Input

There will be several test cases; each case input contains two integers N and M, which satisfy the relationship: 1<=M<=100000000 and 3<=N<=100000000. When N=-1 and M=-1 means the end of input case, and you should not process the data.

Output

For each input case, you should only the result that Haha can find the handkerchief or not.

Sample Input

3 2
-1 -1

Sample Output

YES

题解:

GCD问题

源代码:

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
#include<stdio.h>
#include<stdlib.h>
int gcd(int a,int b)
{

if(b==0)
{
return a;
}
else return gcd(b,a%b);
}
int main()
{

int a,b;
while(scanf("%d%d",&a,&b)!=EOF)
{
if(a==-1&&b==-1)
{
break;
}
if(gcd(a,b)==1)
{
printf("YES\n");
}
else printf("POOR Haha\n");
}
return 0;
}