Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么会WA!!?哪位大佬能给一些测试数据么?

Posted by PG12138 at 2021-01-11 20:30:34 on Problem 1090
#include <iostream>
#include <math.h>
using namespace std ;
int main()
{
    int n = 4 ;
    cin>>n ;
    int a[n] ;
    int b[n] ;
    for (int i = 0; i < n; i++)
    {
        cin >>a[i] ;
        b[i] = 0 ;
    }
    int sum = 0 ;
    for (int i = n-1; i >=0; i--)
    {
        if (a[i] != b[i])
        {
            if (i != 0){
            b[i] = 1 - b[i] ;
            b[i-1] = 1 - b[i-1] ;  
            }
            sum = sum + pow(2 , i) ;
        }
    }
    cout<<sum  ;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator