Advertisement
erfanul007

CF 56 C

Dec 15th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. long long int a[1000000],b[100000];
  4. int main()
  5. {
  6. long long int n,i,k,r,prev,previ,prevn,temp;
  7. scanf("%lld",&n);
  8. for(i=1;i<=n/2;i++){
  9. scanf("%lld",&b[i]);
  10. }
  11. prev=b[1];
  12. previ=0;
  13. prevn=b[1];
  14. for(i=1;i<=n/2;i++){
  15. if(b[i]<=prev){
  16. a[i]=previ;
  17. prevn=b[i]-previ;
  18. a[n-i+1]=prevn;
  19. }
  20. else{
  21. previ=b[i]-prevn;
  22. prevn=b[i]-previ;
  23. a[i]=previ;
  24. a[n-i+1]=prevn;
  25. }
  26. prev=b[i];
  27. previ=a[i];
  28. prevn=a[n-i+1];
  29. }
  30. for(i=1;i<=n;i++){
  31. printf("%d",a[i]);
  32. if(i!=n)
  33. printf(" ");
  34. else
  35. printf("\n");
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement