fork(6) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lli long long int
  4. #define inf 1000000000
  5. #define pb push_back
  6. #define mp make_pair
  7. #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  8. #define endl "\n"
  9. #define yoi cout<<"yo"<<endl;
  10. #define debug(x) cerr << #x << " is " << x << endl;
  11. #define all(x) x.begin(),x.end()
  12. const int mod=1e9+7;
  13. int main(){
  14. IOS;
  15. lli p,q,r,s,i,j;
  16. cin>>p>>q>>r>>s;
  17. lli ans=0;
  18. for(i=p;i<=q;i++){
  19. for(j=r;j<=s;j++){
  20. lli x=max(i,j);
  21. lli y=min(i,j);
  22. while(x&&y){
  23. ans+=(x/y);
  24. x=x%y;
  25. swap(x,y);
  26. }
  27. }
  28. }
  29. cout<<ans;
  30. }
  31.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty