• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Sep 21st, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <bits/stdc++.h>
2. using namespace std ;
3. int main(){
4.     int x , y , a0, z , t , bigtwo , two;
5.     long long b , n , m , ans=0;
6.     cin >> n >> x >> y >> a0;
7.     cin >> m >> z >> t >> b;
8.     vector<int> a(n);
9.     vector<long long>  s(n+1);
10.     s[0]=0 ; a[0]=a0 ; bigtwo=((1<<30)-1) , two=((1<<16)-1) ;
11.     for(int i = 1; i < n; i++){
12.         a[i]=(x*a[i-1]+y)&two;
13.         s[i]=a[i-1]+s[i-1];
14.     }
15.     for(int i = 1; i < n+1; i++){
16.         s[i]=a[i-1]+s[i-1];
17.     }
18.     a.clear() ;
19.     /*for(int i = 1; i < 2*m; i++){
20.         b=(z*b+t)&bigtwo ;
21.         c[i]=b%n ;
22.     }
23.     for(int i = 1; i < 2*m; i+=2){
24.         ans+=s[max(c[i] , c[i-1])+1]-s[min(c[i-1], c[i])];
25.     }
26.     c.clear() ; s.clear() ;*/
27.     long long l , r ;
28.     for(int i = 0; i < 2*m; i+=2){
29.         l=b%n ;
30.         b=(z*b+t)&bigtwo ;
31.         r=b%n ;
32.         b=(z*b+t)&bigtwo ;
33.         ans+=s[max(r,l)+1]-s[min(l, r)];
34.     }
35.     cout << ans ;
36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?