3110 - I2P(I)2024_Yang_hw7 Scoreboard

Time

2024/10/28 17:20:00 2024/10/29 18:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12490 Little Brick's Calculator
13701 fruit sale
14484 Secret Number

12490 - Little Brick's Calculator   

Description

Little Bricks(小磚頭) has a very brilliant calculator,
it can parse the numbers from a sentense and sum up all the numbers in the sentense.

One day, he broke the calculator,
but the calculator cannot be bought anymore,
so he ask you to make a new one for him.

ouo.

Hint:
This is a Partial Judge Problem:
0. You will be provided 2 files below: 'main.c', 'function.h'. You should only upload your 'solver' function inside your '.c' file.
1. The 'main.c' file contains input, output, and function call, the 'function.h' file contains the defination of 'solver' function, and your '.c' file should contain the implement of 'solver' function.
2. You can compile multiple files by command, ex: 'gcc main.c function.h your_code.c', or create a project in your IDE.
3. Remember to include 'function.h'.

 

main.c

 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
#include <stdio.h>
#include "function.h"

#define maxn 1000

char input[1000010];

int main() {
    int sum = 0;
    int a[maxn];
    int *ptr[maxn];

    for (int i = 0; i < maxn; i++) {
        a[i] = 0;
        ptr[i] = &a[i];
    }

    scanf("%s", input);
    int n = solver(ptr, &sum, input);
    printf("%d", a[0]);
    for (int i = 1; i < n; i++)
        printf(" %d", a[i]);
    printf("\n%d\n", sum);
    return 0;
}

function.h

1
2
3
4
5
#ifndef FUNCTION_H
#define FUNCTION_H

int solver(int **ptr, int *sum, char *s);
#endif


For example, if the sentense is 'Now:12/31,23:59',
then you should parse the 4 numbers: 12, 31, 23, 59 out,
and calculate the sum of these numbers, which is 12+31+23+59=129

The numbers should be separate by a space, after a newline character, output the sum of numbers.
Note that your calculator should be able to handle negative number.

Input

Input contain only 1 line, a string S.

It is guarantee that:
0. 1<= |S| <= 10^6
1. Numbers in S will be in the range [-10^5, 10^5]
2. The ammount of number in S will be in the range [1, 1000]

Output

Output contains 2 lines.

The first line should output all numbers appear in the input string S, separate with a space character,
the next line should be the sum of numbers at the first line.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12490.c

Partial Judge Header

12490.h

Tags




Discuss




13701 - fruit sale   

Description

A new supermarket has opened in Bikini Bottom!

Since the supermarket has just opened, the fruit section is having a sale: given a basket, you can fill it with any kind and any amount of fruit. No matter what you have chosen, the whole basket of fruit costs 10 dollars, as long as the basket can bear the weight.

Squidward has made Spongebob and Patrick buy some fruit in this sale for him, please help them figure out the maximum value they could get.

There are only n kinds of fruit left. Each of them has its weight and value. The value of the whole basket of fruit is the sum of the value of each kind of fruit. Squidward only wants to eat at most one unit for each kind of fruit.

Input

The first line contains an integer n, representing the remaining number of fruit.

The second line contains n integers w1, w2 ... wn. Represent each kind of fruit's weight per unit.

The third line contains n integers v1, v2 ... vn. Represent each kind of fruit's value per unit.

The last line contains an integer W, the maximum weight a basket could bear.

 

Constraints:
≤ ≤ 20
≤ wivi≤ 107∈ [1n]

Output

Output the maximum value of the basket that Spongebob and Patrick could get.

Sample Input  Download

Sample Output  Download

Tags

FlyHighHigh temmie bad



Discuss




14484 - Secret Number   

Description

Secret Number is a number guessing game where the questioner thinks of a number between 1 and 100. We can ask about a number, and the questioner will tell us if it is higher or lower than his number.

We know that the fastest way to guess the number is by asking about the middle value each time, reducing the options by half. This idea is called Binary Search.


Now, there's no questioner to answer you, and this game will be played T times. Each time, you'll receive a number M, and you need to find its position P in a sorted array A of length N.


Hint:
If you get a TLE, try to think about how to use the number guessing game strategy to quickly find M.

Input

The first line contains two integers N and T. N represents the length of the array, and T represents the number of games to be played.

The second line contains N numbers, representing the numbers Ai in the array, guaranteed to be sorted in increasing order. Each number appears only once.

The following T lines each contain a number M, representing the number to find in the jth round. Mj is guaranteed to be in array A.

Constraints

  • 1 ≤ T ≤ 105
  • 1 ≤ N ≤ 106
  • 0 ≤ Ai ≤ 109
  • 1 ≤ P N

Output

Output T lines, each containing a number Pj, representing the position of Mj in the array for the jth round.

 

Please remember to print "\n" at the end.

Sample Input  Download

Sample Output  Download

Tags

這麼臭的測資有存在的必要嗎?(惱



Discuss