Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include<set>
- #include<map>
- #include<vector>
- using namespace std;
- #define ll long long
- #pragma GCC optimize("Ofast")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
- int p_x0,p_x1,p_x2;
- int a,b,c,d;
- inline int f(int x1,int x2,int x3){
- return ((ll)a*(ll)x3+(ll)b*(ll)x2+(ll)c*(ll)x1)%d;
- }
- inline void floyd(){
- int l_x0=p_x0,l_x1=p_x1,l_x2=p_x2,k;
- for(int i=0;i<d;i++){
- k=l_x2;
- l_x2=f(l_x0,l_x1,l_x2);
- l_x0=l_x1;l_x1=k;
- }
- int r_x0=l_x1,r_x1=l_x2,r_x2=f(l_x0,l_x1,l_x2);
- int cnt=0;
- while(r_x0!=l_x0||r_x1!=l_x1||r_x2!=l_x2){
- k=r_x2;
- r_x2=f(r_x0,r_x1,r_x2);
- r_x0=r_x1;r_x1=k;
- cnt++;
- }
- int N=cnt+1;
- l_x0=p_x0;l_x1=p_x1;l_x2=p_x2;
- r_x0=p_x0;r_x1=p_x1;r_x2=p_x2;
- // l_x0=p_x1;l_x1=p_x2;l_x2=f(p_x0,p_x1,p_x2);
- // r_x0=p_x1;r_x1=p_x2;r_x2=f(p_x0,p_x1,p_x2);
- for(int i=0;i<N;i++){
- k=r_x2;
- r_x2=f(r_x0,r_x1,r_x2);
- r_x0=r_x1;r_x1=k;
- }
- cnt=0;
- while(r_x0!=l_x0||r_x1!=l_x1||r_x2!=l_x2){
- k=l_x2;
- l_x2=f(l_x0,l_x1,l_x2);
- l_x0=l_x1;l_x1=k;
- k=r_x2;
- r_x2=f(r_x0,r_x1,r_x2);
- r_x0=r_x1;r_x1=k;
- cnt++;
- }
- int P=cnt;
- vector<int> cnt2(20,0);
- for(int j=0;j<20;j++){
- if(j*d<=20*p_x0&&20*p_x0<(j+1)*d){
- cnt2[j]++;
- break;
- }
- }
- for(int j=0;j<20;j++){
- if(j*d<=20*p_x1&&20*p_x1<(j+1)*d){
- cnt2[j]++;
- break;
- }
- }
- for(int j=0;j<20;j++){
- if(j*d<=20*p_x2&&20*p_x2<(j+1)*d){
- cnt2[j]++;
- break;
- }
- }
- r_x2=f(p_x0,p_x1,p_x2),r_x1=p_x1,r_x0=p_x1;
- for(int i=0;i<398;i++){
- for(int j=0;j<20;j++){
- if(j*d<=20*r_x1&&20*r_x1<(j+1)*d){
- cnt2[j]++;
- break;
- }
- }
- k=r_x2;
- r_x2=f(r_x0,r_x1,r_x2);
- r_x0=r_x1;r_x1=k;
- }
- int sm=0;
- for(int i=0;i<cnt2.size();i++){
- sm+=(cnt2[i]-20)*(cnt2[i]-20);
- }
- double Q=sm/400.0;
- cout.precision(2);
- cout<<fixed;
- cout<<N<<" "<<P<<" "<<Q;
- }
- signed main() {
- ios::ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int x0,x1,x2;
- cin>>a>>b>>c>>d>>p_x0>>p_x1>>p_x2;
- floyd();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement