fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. int main() {
  7. // Write C++ code here
  8.  
  9. int t;
  10. cin>>t;
  11. while(t--)
  12. {
  13. int x;
  14. cin>>x;
  15. if(x%3==0)
  16. {
  17. cout<<0<<endl;
  18.  
  19. }
  20. else
  21. {
  22. int y=ceil(x/3)*3;
  23. cout<<y-x<<endl;
  24.  
  25. }
  26.  
  27. }
  28.  
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0.01s 5324KB
stdin
2
7
24
stdout
-1
0