Advertisement
Guest User

Untitled

a guest
Nov 14th, 2021
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. /* Bismillahir Rahmanir Rahim */
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5. typedef long long int ll;
  6. typedef long double ld;
  7. typedef vector<ll> vll;
  8. #include <ext/pb_ds/assoc_container.hpp>
  9. #include <ext/pb_ds/tree_policy.hpp>
  10. using namespace __gnu_pbds;
  11. typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
  12. #define fi first
  13. #define se second
  14. #define pb push_back
  15. #define Fin freopen("input7.txt","r",stdin)
  16. #define Fout freopen("output7.txt","w",stdout)
  17. #define nn "\n"
  18. #define all(p) p.begin(),p.end()
  19. #define zz(v) (ll)v.size()
  20. #define S(a) scanf("%lld",&a)
  21. #define SS(a,b) scanf("%lld %lld",&a,&b)
  22. #define SSS(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
  23. #define ss ' '
  24. #define pii pair<ll,ll>
  25. #define gcd(a,b) __gcd(a,b)
  26. #define lcm(a,b) (a*b)/gcd(a,b)
  27.  
  28. const ll N = 1009;
  29.  
  30.  
  31.  
  32. int main()
  33. {
  34.  
  35. ios::sync_with_stdio(0);
  36. cin.tie(0);
  37.  
  38. // Fin;
  39. // Fout;
  40.  
  41.  
  42. ll t;
  43. cin>>t;
  44.  
  45. while(t--)
  46. {
  47. ll a,b,m;
  48. cin>>a>>b>>m;
  49.  
  50. ll ans = gcd(a-m,b-m);
  51.  
  52. cout<<ans<<nn;
  53. }
  54.  
  55.  
  56.  
  57.  
  58. /* you should actually read the stuff at the bottom */
  59.  
  60. }
  61.  
  62. /*
  63.  
  64. * do something instead of nothing and stay organized
  65. * WRITE STUFF DOWN
  66. * DON'T GET STUCK ON ONE APPROACH
  67. */
  68.  
  69.  
  70. /* Final check before submit :
  71.  
  72. 1. array size or integer overflow,like uninitialised 0 index.
  73.  
  74. 2. Think twice,code once.check all possible counter test case.
  75.  
  76. 3. Be careful about corner case! n=1?k=1? something about 0?
  77.  
  78. 4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?
  79.  
  80. 5. if got WA than remember that you are missing something common.
  81. *** Be confident!!! who knows? may be your one step back to AC ***
  82. 4. minus mod ans=(ans-k+mod)%mod;
  83.  
  84.  
  85.  
  86. */
  87.  
  88.  
  89. /* IF WA???
  90.  
  91. 1. corner case! n=1?k=1? something about 0?
  92.  
  93. 2. check code(avoid stupid mistake)
  94.  
  95. 3. read the statement again(if there any missing point???)
  96.  
  97. 4. check the idea(check all possible counter test case again!!!)
  98.  
  99. 5. be calm,don't be panic!!!.(***this problem not going to decide your future***)
  100.  
  101. 6. don't waste too much time. move to next problem
  102.  
  103. */
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement