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;
		}
	}
}
上一篇:CG.DYJ-顺序表比较


下一篇:MarkDown基础语法学习