#46705: 問下這是哪裡出錯了


lingolin22@gmail.com (LINLIN)

學校 : 不指定學校
編號 : 123768
來源 : [180.176.70.103]
最後登入時間 :
2025-07-13 22:26:59

#include <iostream>
using namespace std;
int main()
{
    int a,b;//紅燈秒數&綠燈秒數
    int n;//人數
    int sum=0;//停紅燈的秒數
    int num=0;//每個人停紅燈的秒數總和
    cin>>a>>b;
    cin>>n;
    int stop=a+b;
    for(int i=0;i<n;i++){
        int need=0;
        cin>>sum;
        if((sum%stop)>b){
            need=stop-(sum%stop);
            num=num+need;
        }
    }
    cout<<num<<endl;
}