1805 - I2P(I)2019_Hu_mid1_re_examine Scoreboard

Time

2019/10/28 18:30:00 2019/10/28 21:36:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12423 ID Card Verification
12448 Hu_cheatsheet
12461 Reservoir's Volume
12462 Land Valuation System

12423 - ID Card Verification   

Description

With the improvement of your programming skill, you receive the invitation from government to design an ID card verification program. The government give you the rule of ID card below:

The ID number have special encode rule. The first word is uppercase English letter and remaining 9 words must be numbers, when applying the special encode rule, the first word will be encode to a number. (encoded by following table)

A B C D E F G H J K L M N
10 11 12 13 14 15 16 17 18 19 20 21 22
P Q R S T U V X Y W Z I O
23 24 25 26 27 28 29 30 31 32 33 34 35

The encoded ID number will be 11 digits in total and each of digit has a fixed weight from left to right(1 9 8 7 6 5 4 3 2 1 1 ). If the ID number is real, the ID number must follow the rule bellow:

"sum of each digit multiply with each weight can be divided by 10"

Take ID A135607214 for example, it can first be translate to 10135607214 and then use the special rule to compute the value 1*1 + 0*9 + 1*8 + 3*7 + 5*6 + 6*5 + 0*4 + 7*3 + 2*2 + 1*1 + 4*1 = 120. Since 120 can be divided by 10 then A135607214 is the real

Input

Input the ID card number need to examine

Output

Print out the result of verification. If the card number is true then print "Real", otherwise pint "Fake".(followed by a newline character at the end of the output string)

Sample Input  Download

Sample Output  Download

Tags




Discuss




12448 - Hu_cheatsheet   

Description

printf() and  scanf() format

printf("%d", n);
 

FORMAT  ARGUMENT TYPE

%d, %i  int           decimal

%lld    long long

%llu    unsigned long long

%u      unsigned int

%x      unsigned int  hexadecimal

%#x     unsigned int  hexadecimal with prefix 0x

%f      double  

%Lf     long double

%c      char         to print a character

%s      char *      string (character array ended with '\0')


scanf("%d", &n);
 

FORMAT  ARGUMENT TYPE

%d      int *       &n, store the input integer in n

%ld     long *

%lld    long long *

%u      unsigned int *

%f      float *     read float

%lf     double *    read double

%Lf     long double *   read long double

%c      char *      read 3 characters %3c

%s      char *      read a string until whitespace

%n      int *       with %s, to get string length

                   char a[100]; int len; 
                 scanf("%s%n", a, &len);
                 len
 will have the string length

 

Frequently used functions

#include <string.h>
char str[10];
scanf("%s", str);
to get the string length using strlen(str)

#include <ctype.h>
isspace(ch), islower(ch), isupper(ch), isdigit(ch)
isalpha(ch), toupper(ch), tolower(ch)

To create 5-by-5 two-dimensional array, we need to write

int a[5][5];

 

It will be indexed as follows:

 

 a[0][0] 

 a[0][1]

 a[0][2]

 a[0][3]

 a[0][4]

 a[1][0]

 a[1][1]

 a[1][2]

 a[1][3]

 a[1][4]

 a[2][0]

 a[2][1]

 a[2][2]

 a[2][3]

 a[2][4]

 a[3][0]

 a[3][1]

 a[3][2]

 a[3][3]

 a[3][4]

 a[4][0]

 a[4][1]

 a[4][2]

 a[4][3]

 a[4][4]

 


 

 


How to read the following data?
1 2 3 4 5 e
#include <stdio.h>

int main(void)
{
    int x;
    while (scanf("%d", &x) == 1) {  
     
printf("x=%d\n", x);
    }
    return 0;
}

How to read the following data?

2

L 5 2
D 5 3

#include <stdio.h>

int main(void)

{

   char ch;
   int i, n, row, col;

   scanf("%d", &n);

   for (i=0; i<n; i++) {

      while(getchar()!='\n');

      scanf("%c%d%d", &ch, &row, &col);

   }

   return 0;

}

 

Using for loops to print a two-dimensional array

   for(i = 0; i < row; i++) {
      for (j = 0; j < col; j++) {
         printf("%5d", A[i][j]);
      }
      printf("\n");
   } 

logical and comparison operators operators:
!    &&    ||    ==     !=    >   <     >=    <=

arithmetic operators:

+    -    *    /    %

bitwise operators:

&    |    ^    <<    >>    ~

int strcmp(const char *lhs, const char *rhs);

int strcat(const char *lhs, const char *rhs);

int strcpy(const char *lhs, const char *rhs);

How to avoid common errors and how to debug for OJ

1. Put the arrays in the 'global' area. Set their size bigger than required. Avoid using variable-length arrays (e.g. int arr[n];). Keep the array size fix (e.g., int arr[1000];).

2. After writing the code for reading input data, you may print out the data to check if your code reads them correctly. Do not proceed to write subsequent code before you confirm that.

3. If your program crashes, usually it is caused by memory related errors. Check the ranges of for-loops to see if your code attempts to read or write the elements out of the arrays' boundary.

Note : If you are using visual studio, add #pragma warning(disable:4996) in the first line so that you can use scanf on your local machine.

Input

Output

Sample Input  Download

Sample Output  Download

Tags




Discuss




12461 - Reservoir's Volume   

Description

As the member of Water resources bureau (水利局), Your job is to compute the total volume of Reservoir (水庫) by an elevation map.

Take an example below:

The above elevation map can be represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 unit of water is the total volume of Reservoir (水庫)

Note that: If you are using visual studio, add #pragma warning(disable:4996) in the first line so that you can use scanf on your local machine.

Input

N

S_1 S_2 ... S_N

Given an elvation map with the length of N ( 3 <= N  < 3000) with each element S_i (0 <= S_i < 1000) 

Output

Compute the total volume of Reservoir (水庫).(followed by an newline character at the end of output string)

Sample Input  Download

Sample Output  Download

Tags




Discuss




12462 - Land Valuation System   

Description

(modifyied by predix sum)

One day, the government want to know the total valuation of the land in rectangular area. As the member of the government, you decided to pick up this project and develop an query system. The example show below:

First, the government will give you each land's valuation with specific size 

Second, the government will give two point (top-left point and bottom-right point), and you need to compute the valuaiton of the land with specific area

ex1: (2,2) (3,3) ==>  the valuation of land is 10 + 20 + 4 + 6 = 40

ex2: (1,1) (2,2)  ==>  the valuation of land is 10 + 20 + 5 + 10 = 45

ex3: (1,3) (3,3)  ==>  the valuation of land is 30 + 20 + 6 = 56

Hint : If you get TLE for last two testcases, you should think how to decrease some redundant operations for calculations (you can try to expand 1D prefix sum to 2D prefix sum)

Note that: If you are using visual studio, add #pragma warning(disable:4996) in the first line so that you can use scanf on your local machine.

Input

M N

S11  S12 . .. S1N

...

SM1 SM2 ...SMN

T

pma_1 pna_1 pmb_1 pn b_1

pma_1 pna_2 pmb_2 pn b_2

....

pma_T pna_T pmb_T pn b_T

 

pm1_1 pn1_1 pm2_1 pn 2_1

M : the row size ( 2 < M < 1000)

N:  the column size (2 < N < 1000)

Sij: the element in the 2D array (0 <= Sij < 100)

T : the times of query (2 <= T < 5000)

pma_i pna_i pmb_i pnb_i : the top-left point and bottom-right point

( 1 <= pma_i <= pmb_i <= M)

( 1 <= pna_i <= pnb_i <= N)

Output

Compute the valuaiton of specific land area (followed by a newline character at the end of  each output answer).

Sample Input  Download

Sample Output  Download

Tags




Discuss