比赛 20101116 评测结果 AAAAAAAAAA
题目名称 长路上的灯 最终得分 100
用户昵称 lc 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2010-11-16 11:06:19
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<fstream>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn = 60,INF = 1000000000;
int N;
int res[100],Two[100];
long long power[100],Ans;


void Change(long long A)
{
	int top = 0;
	while (A)
	{
		res[++top] = A%2; A = A/2;
	}
	for (int i=1; i<=top; i++) Two[i] = (Two[i] + res[i])%2;
}

void prep()
{
	scanf("%d",&N);
	for (int i=1; i<=N; i++)
	{
		double a; int t;
		scanf("%lf%d",&a,&t);
		for (int j=1; j<=t; j++)
		{
			double x = a * j;
			long long A = (long long)x;
			Change(A);
		}
	}
}

void work()
{
	ofstream fout("light.out");
	power[0] = 1;
	for (int i=1; i<=40; i++) power[i] = power[i-1]*2;
	//for (int i=1; i<=40; i++) fout<<power[i]<<endl;
	for (int i=1; i<=40; i++)
		if (Two[i]==1)
		{
			Ans += power[i-1];
		}
	fout <<Ans <<endl;
	fout.close();
}

int main()
{
	freopen("light.in","r",stdin);
	prep();
	work();
	return 0;
}