P1161 开灯(C/C++)

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
直接暴力解题就可以了

#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include <algorithm>
#include<string.h>
#include<math.h>
#define llu unsigned long long
using namespace std;
int main()
{
    
    
	//cout << fixed << setprecision(0);
	//cout << setw(8) << setiosflags(ios::left);
	bool b[2000010]={
    
    0};
	int n;
	cin >> n ;
	for(int i=0;i<n;i++)
	{
    
    
		long long T;
		double a;
		int t;
		cin >> a >> t ;
		for(int j=1;j<=t;j++)
		{
    
    
			T=a*j;
			if(b[T]==0) b[T]=1;
			else b[T]=0;
		}
	}
	for(int i=1;i<=2000000;i++)
	{
    
    
		if(b[i]==1){
    
    
			cout << i << endl ;
		  	break;
     	}
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/wangyurenwls/article/details/118554626
今日推荐