22198_Stupid

2022-5-16 18:21| 发布者: Hocassian| 查看: 27| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506193615899-Problem List-采集的数据-后羿采集器.html

Pro.ID

22198

Title

Stupid

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22198

AC

0

Submit

15

Ratio

0.00%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Xiaoming is an intern of M company. He always reads the program written by his colleagues to fix bugs. But he found some of the programs are really stupid. As a smart guy, how can he bear this? There is an example below. How ugly it is! Maybe you can help him to rewrite this function.

    int Stupid( int A[maxn],int B[maxn],int n )
    {
     int i,j,ans=0;
     for(i=0; i<n; i++){
       if ( A[i]==B[i] ) continue;
       ans++;
       for(j=i; j<n; j++){
         if( A[j]==B[j]&& A[j]!=B[i] ) break;
         A[j]=B[i];
       }
     }
     return ans;
    }

    输入

    The first line contains an integer n indicating the length of arrays. ( n ≤ 100000 )

    The second line contains n 32-bit integers of array A.

    The third line contains n 32-bit integers of array B.

    Multiple inputs. Process to the end of file.

    输出

    Description

    Xiaoming is an intern of M company. He always reads the program written by his colleagues to fix bugs. But he found some of the programs are really stupid. As a smart guy, how can he bear this? There is an example below. How ugly it is! Maybe you can help him to rewrite this function.

    int Stupid( int A[maxn],int B[maxn],int n )
    {
     int i,j,ans=0;
     for(i=0; i<n; i++){
       if ( A[i]==B[i] ) continue;
       ans++;
       for(j=i; j<n; j++){
         if( A[j]==B[j]&& A[j]!=B[i] ) break;
         A[j]=B[i];
       }
     }
     return ans;
    }

    Input

    The first line contains an integer n indicating the length of arrays. ( n ≤ 100000 )

    The second line contains n 32-bit integers of array A.

    The third line contains n 32-bit integers of array B.

    Multiple inputs. Process to the end of file.

    Output

    For each case, output Stupid( A, B, n ) on a single line.

    Sample Input

    6
    0 0 0 0 0 0
    1 2 1 2 1 2

    Sample Output

    4

    Source

    样例输入

    6
    0 0 0 0 0 0
    1 2 1 2 1 2

    样例输出

    4

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部