Zheng Qing's sixth school competition, sixth school

1427: digital conversion Time Limit: 1 Sec Memory Limit: 128 MB

Submit: 379 Solved: 93

SubmitStatusWeb Board Description

The instructor handed me a task with two numbers x and y (x <y). perform the following two operations: 1. Multiply x by 2; 2. Add 1 to the value of x. James hopes to complete this task with as few operations as possible, but he does not know how to do it. Please help him now.

Input

Two integers x and y (0 <= x <y <= 10 ^ 6 ).

Output

An integer n indicates the minimum number of operations performed, and x can be changed to y.

Sample Input2 510 80 Sample Output23HINT

Source

Zheng Qing's sixth school Competition

**When I had nothing to brush other people's school competition questions, I felt quite watery. I had 6 questions. Maybe today's status is okay, but today there is still a dictionary tree stuck ,, let's take a look next time... (I'm addicted to it when I click it. I'm not going to see big things anymore. I will read a book and review it tomorrow)**

**AC code:**

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main(){int x, y;while(scanf("%d %d", &x, &y) != EOF){int cnt = 0;if(x == 0) { x = 1; cnt++; }while(x != y){if(y/2 >= x){cnt++;if(y&1) cnt++;y = y / 2;}else{y--;cnt++;}} printf("%d\n", cnt);}return 0;}

1428: mysterious password Time Limit: 1 Sec Memory Limit: 128 MB

Submit: 256 Solved: 147

SubmitStatusWeb Board Description

Xiao Q is a standard IT otaku, and also a cool man, focusing on encryption and decryption algorithms. He is so fond of encryption and decryption that he is still thinking about encryption and decryption this evening ~.

In his dream, he accidentally entered a world of passwords, and there were unordered integers floating in this small world. The key to breaking into this small world is to find the so-called "Password Key". The key is a string consisting of the integers in the sky. At the same time, he does not scientifically know the correct order of these integers. We also know that each character in each string is an ASCII character corresponding to an integer. The key to the problem is that he does not remember the ASCII ing between integers and characters.

"What should I do? Can't I leave T_T here? I like decryption very much, ..

They also have female friends,

People have not yet earned Money,

People have not bought a car,

People have not bought a house yet,

No one else...

People's home .. Wow ...." Okay, that's all .. Crying...

Forgive me for this kid's shoes who only know the technology and don't know the world. Can you help him with swelling?

Input

T (1 <= T <= 100) group is input.

Each group has an integer n (1 <=n <= 1000), followed by n integers.

Make sure that the input is valid.

Output

For each group, please output the Password Key, each group occupies one line.

Sample Input127 65 67 77 32 105 115 32 104 101 108 116 104 121 44 32 106 117 115 32 116 100 111 105 33 Sample OutputACM is healthy, just do it! HINT

Source

Zheng Qing's sixth school Competition

**AC code:**

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[1005];int main(){int T, n;scanf("%d", &T);while(T--){scanf("%d", &n);for(int i=0; i<n; i++){scanf("%d", &a[i]);}for(int i=0; i<n; i++)printf("%c", a[i]);printf("\n");}return 0;}

1430: How many 0 Time Limit: 1 Sec Memory Limit: 128 MB

Submit: 213 Solved: 56

SubmitStatusWeb Board Description

There is an n * n square, and there is a number in the middle of each box is 2 or 5. Now, from the upper left corner of the square to the lower right corner, you can only choose to move one box down or to the right at a time, multiply all the numbers in the passing lattice to minimize the number 0 at the end of the final result.

Input

The first line is a positive integer n (0 <n <100 ).

The next n rows are a matrix of n * n.

Output

A positive integer m, indicating that at least m 0 is at the end of the final result.

Sample Input42 5 2 55 2 5 22 5 52 2 2 2 Sample Output1HINT

Source

Zheng Qing's sixth school Competition

**Idea: DP, go to 2 and 5 and set the maximum number in one path (top left to bottom right)**

**AC code:**

#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;int n;int a[105][105];int dp2[105][105];int dp5[105][105];int main(){while(scanf("%d", &n) != EOF){for(int i=1; i<=n; i++)for(int j=1; j<=n; j++)scanf("%d", &a[i][j]);memset(dp2, 0, sizeof(dp2));memset(dp5, 0, sizeof(dp5));if(a[1][1] == 2) dp2[1][1] = 1;else dp5[1][1] = 1;for(int i=2; i<=n; i++){for(int j=1; j<=i; j++){dp5[i][j] = max(dp5[i-1][j], dp5[i][j-1]);dp2[i][j] = max(dp2[i-1][j], dp2[i][j-1]);if(a[i][j] == 2) dp2[i][j]++;else dp5[i][j]++;dp5[j][i] = max(dp5[j][i-1], dp5[j-1][i]);dp2[j][i] = max(dp2[j][i-1], dp2[j-1][i]);if(a[j][i] == 2) dp2[j][i]++;else dp5[j][i]++;}} int ma = max(dp2[n][n], dp5[n][n]);//printf("%d %d\n", dp2[n][n], dp5[n][n]);printf("%d\n", 2 * n - 1 - ma);}return 0;}

1432: backpack againTime Limit: 1 Sec Memory Limit: 128 MB

Submit: 193 Solved: 53

SubmitStatusWeb Board Description

Gy recently learned about the 01 backpack problem. When bored, he thought of a new problem. The value of n items is the same as that of the 01 backpack, each item can only be selected once or 0 times, and the minimum value cannot be obtained.

Input

The first line is a positive integer T (T <= 100), indicating that T groups of data exist.

The input format of each group of data is as follows:

The first behavior is a positive integer N (N <= 100), indicating the number of items.

N positive integers in the second row, indicating the value of each item vi (1 <= vi <= 1000000)

Output

T rows are output, that is, the answers to each group of data.

Sample input00004 841 2 4 8 Sample output0000hint

Source

Zheng Qing's sixth school Competition

**AC code:**

# Include <cstdio> # include <cstring> # include <algorithm> using namespace std; const int N = 110; int a [N]; int main () {int T; scanf ("% d", & T); while (T --) {int n, m; scanf ("% d", & n); for (int I = 0; I <n; I ++) scanf ("% d", & a [I]); sort (a, a + n); m = 0; // m indicates that from 0 to m can be obtained (DP idea) for (int I = 0; I <n; I ++) {if (a [I]-m> 1) // if the current number is greater than 1 than m, m + 1 is the smallest value, proof can be used to prove that break; m = m + a [I];} printf ("% d \ n", m + 1); // because 0 to m can be obtained, so m + 1 cannot be obtained} return 0 ;}

1433: What are you doing? Time Limit: 1 Sec Memory Limit: 128 MB

Submit: 221 Solved: 103

SubmitStatusWeb Board Description

"Hey my friends! What are you doing ?"

My friends have been expecting to spend some time in college for over N years. I don't know what everyone is busy? Are you sure you want to find your own goals?

It is said that a gang called LOL has been born, affecting countless college students. There are two aggressive roles, PanSen (PS) and JanSheng (JS ). These two guys are famous for their aggressive nature and known as "duxiong" by outsiders ". But none of them agree with each other. As long as they meet each other, they will greet each other affectionately. (Of course, in their own words, they are transmitting love and friendship. If you don't pass by, you will always feel a little cruel ..)

Just now, the two guys have met again.

"Bald, then, the best practice has finally been achieved. Each Xth attack can release a major attack, which can cause a c-fold damage to you. !" PS path.

"Yo ~, Who was I at that time? I just got a little bit of skill. Each attack can trigger a mental state after y times. Each attack that starts from the next time and runs for z times can cause double damage, after the last z attacks, the system retries to charge the next state of God. Let me entertain you '!" JS return.

"Fill in for public sows and for large pig pigs ~" The passer-by shouted.

"Shut up !", "Shut down !" Shuangxiong turned his head and sent a message at the same time.

"If you have any bad feelings, you can beat them out. The Ancients will not bully me ..", Passers-by B whispered.

Shuang Xiong is full of brains and fight continues ....

Okay, this battle happened just now. So I will tell you some information. Can you tell me who won the battle?

Known:

1. Each PS attack can cause JavaScript to lose a point of blood, and each JS attack can cause PS to lose B points of blood;

2. PS has blood HP_p, JS has blood HP_j, and if the blood volume is not greater than 0, it indicates failure and the battle is over;

3. According to unwritten rules, the two men attack each other in turn, and JS first launches an attack.

Input

The input has a T group.

Each group reads multiple integers in order:

HP_p, HP_j (0 <HP_p, HP_j <= 1000), indicating the life values of PanSen and JanSheng;

A, B, c, x, y, z (0 <a, B, c, x, y, z <= 1000), meaning as above.

The input must be valid.

Output

For each group, the name of the winner is abbreviated, and each group occupies one row.

Sample Input210 10 1 1 2 9 9 210 10 1 1 2 9 7 2 Sample OutputPSJSHINT

Moderate LOL can respond quickly and wait for the supreme success, but excessive LOL is detrimental to physical and mental health, moderate is good.

Hope that you will find your goal and be successful as soon as possible.

Source

Zheng Qing's sixth school Competition

**AC code:**

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main(){int T;int PS, JS, a, b, c, x, y, z;scanf("%d", &T);while(T--){scanf("%d %d %d %d %d %d %d %d", &PS, &JS, &a, &b, &c, &x, &y, &z);int cur = 1;while(1){if(PS <= 0 || JS <= 0) break;if(cur % x == 0) JS -= c;else JS -= a;if((cur-1) % ( y + z ) <= y) PS -= b;else PS -= 2*b;cur++;}if(PS <= 0) printf("JS\n");else printf("PS\n");}return 0;}

1435: A + BTime Limit: 1 Sec Memory Limit: 128 MB

Submit: 159 Solved: 114

SubmitStatusWeb Board Description

Like A + B.

Read two A and B in English, calculate their sum and output.

Input

Enter A string in the first line, indicating the number A. Enter A string in the second line indicating the number B. Both A and B are positive integers.

Output

Returns A positive integer n, indicating the sum of A + B**(A + B <100 ).**

Sample Inputone fivefourthree fourtwo sixSample Output1960HINT

The corresponding English words from 0 to 9 are: zero, one, two, three, four, five, six, seven, eight, nine.

Source

Zheng Qing's sixth school Competition

**AC code:**

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int fun(char a[]){int len = strlen(a), ans = 0;for(int i=0; i<len; i++){if(a[i] == 'z' && a[i+1] == 'e') { ans = ans * 10 + 0; i += 4; }else if(a[i] == 'o' && a[i+1] == 'n') { ans = ans * 10 + 1; i += 3; }else if(a[i] == 't' && a[i+1] == 'w') { ans = ans * 10 + 2; i += 3; }else if(a[i] == 't' && a[i+1] == 'h') { ans = ans * 10 + 3; i += 5; }else if(a[i] == 'f' && a[i+1] == 'o') { ans = ans * 10 + 4; i += 4; }else if(a[i] == 'f' && a[i+1] == 'i') { ans = ans * 10 + 5; i += 4; }else if(a[i] == 's' && a[i+1] == 'i') { ans = ans * 10 + 6; i += 3; }else if(a[i] == 's' && a[i+1] == 'e') { ans = ans * 10 + 7; i += 5; }else if(a[i] == 'e' && a[i+1] == 'i') { ans = ans * 10 + 8; i += 5; }else if(a[i] == 'n' && a[i+1] == 'i') { ans = ans * 10 + 9; i += 4; }}return ans;}int main(){char str1[205], str2[205];while(gets(str1) != NULL){gets(str2);printf("%d\n", fun(str1) + fun(str2));}return 0;}