其他分享
首页 > 其他分享> > P1161 开灯

P1161 开灯

作者:互联网

题面

这题刚开始卡住了,没有理解每组第二个b是什么,以为是ab,2ab,3ab,4ab,…,nab,所以卡住了实际上是边界n,即到ab终止

#include<iostream>
#include<algorithm>
using namespace std;
double a;
int b;
int lamp[2000005];
int main()
{
	int n;
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> a >> b;
		for (int j = 1; j<=b; j++)
		{
			if (lamp[int(a * j)] == 1)lamp[int(a * j)] = 0;
			else
				lamp[int(a * j)] = 1;
		}
	}

	for (int i = 1;; i++)
	{
		if (lamp[i] == 1)
		{
			cout << i;
			break;
		}
	}
}

标签:ab,int,开灯,卡住,cin,lamp,P1161,include
来源: https://blog.csdn.net/m0_57255328/article/details/119303298