各位大佬,感觉逻辑没问题,帮忙看看为什么运行会直接结束,连输入都没输入就结束了
  • 板块P1161 开灯
  • 楼主songyikang
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/1/19 23:03
  • 上次更新2024/1/20 10:38:33
查看原帖
各位大佬,感觉逻辑没问题,帮忙看看为什么运行会直接结束,连输入都没输入就结束了
412341
songyikang楼主2024/1/19 23:03
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int main() {
    int n;
    cin>>n;
    int light[2000010];
    memset(light,-1,sizeof(light));     //一开始全关闭为-1
    double set[5001][2];        //n个a和t
    for(int i=1;i<=n;i++){
        cin>>set[i][0]>>set[i][1];              //输入a和t
        for(int j=1;j<=set[i][1];j++){
            light[(int)(set[i][0]*j)]*=(-1);        //变灯
        }
    }
    for(int i=1;i<=2000000;i++){                //找亮着的灯
        if(light[i]==1){
            cout<<i;
            break;
        }
    }
    return 0;
}
2024/1/19 23:03
加载中...