Advertisement
a53

roata1

a53
May 9th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include<iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream f("roata.in");
  7. ofstream g("roata.out");
  8.  
  9. long long n,x,i,k,suma,a,poz[100010];
  10.  
  11. int main()
  12. {
  13. f>>n;
  14. for(i=0; i<n; i++)
  15. f>>x,poz[x-1]=i;
  16. x=0;
  17. for(i=0; i<n; i++)
  18. {
  19. k=n-(suma+poz[i])%n;
  20. if(k<=x)
  21. a=a+n;
  22. x=k;
  23. k=k+a;
  24. suma=suma+k;
  25. g<<k<<" ";
  26. }
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement