Luo Gu P1161 lights

Title Description

In an infinitely long road, there is a row of lights infinitely long, numbered 1,2,3,4, ... .

Each lamp has only two possible states, on or off. If you click on a lamp switch, then the state of this lamp will change. If the original is open, it will become off. If the original is off, it will become open.

In the beginning, all the lights are off. Bob can each operate as follows:

Specifies two numbers, A, t ( A is a real number, T is a positive integer). Will be numbered as [a], [2 × a ], [3 × a], ..., [t × a] switch each time the lamp. Where [k] is a real number k integer part.

In Xiao Ming was n after operations, Xiao Ming suddenly discovered, this time only one lamp is open, Xiao Ming would like to know which lamp number, but this lamp from Xiao Ming too far, Xiao Ming see the number is how many .

Fortunately, Xiao Ming remember the previous n operations. So Xiao Ming found you, you can help him calculate this lamp lights numbers open it?

Input Format

The first line of a positive integer n , denotes n operations.

Then there are n lines of two numbers, AI, Ti . Where ai is a real number, there must be a decimal . 6 bit, Ti I is a positive integer.

Output Format

Only a positive integer, the number of light open lodge.

Sample input and output

Input # 1
3
1.618034 13
2.618034 7
1.000000 21
Output # 1
20

Description / Tips

Note T = T1 + T2 + T3 + ... + TN .

For 30% of the data, to meet T≤1000

For 80% of the data, to meet T≤200000

For 100% data satisfies T≤2000000

For 100% data satisfies n≤5000,1≤ai <1000,1≤ti≤T

Data guarantee, after n after operations, and only one lamp is open, do not have a wrong judgment.

 

 1 #include<bits/stdc++.h> 
 2 #define f(i,j,n) for(i=j;i<=n;i++) 
 3 using namespace std;
 4 int main()
 5 {
 6     ios::sync_with_stdio(false); 
 7     int n,t,i,j,ans=0;
 8     double a; 
 9     cin>>n;
10     f(i,1,n)
11     {
12         cin>>a>>t;
13         f(j,1,t)
14             ans^=int(j*a); 
15     }
16     cout<<ans<<endl; 
17     return 0; 
18 }

 

 

 

Guess you like

Origin www.cnblogs.com/anbujingying/p/11294166.html