Advertisement
Rofyda_Elghadban1

Untitled

Sep 7th, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. #include <algorithm>
  5. #include <cstdlib>
  6. #include <limits.h>
  7. #include <string>
  8.  
  9. #define ll long long
  10.  
  11. using namespace std;
  12. void Fast_IO();
  13. void Rofyda_Elghadban(){
  14. #ifndef ONLINE_JUDGE
  15. freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  16. #endif
  17. }
  18.  
  19.  
  20.  
  21. int main()
  22. { Rofyda_Elghadban();
  23. //Fast_IO();
  24. //freopen("input.txt","r",stdin);
  25. //freopen("output.txt","r",stdout);
  26. ll a,b,x,sum=0;
  27. cin>>a>>b>>x;
  28. if(b>=a){
  29. if(b==x){
  30. cout<<b;
  31. }else{
  32. for(ll i=a;i<=b;i++){
  33. if(i%x==0){
  34. sum+=i;
  35. }
  36. }cout<<sum;
  37. }
  38. }else if(b<a){
  39. for(int i=b;i<=a;i++){
  40. if(i%x==0){
  41. sum+=i;
  42. }
  43. }cout<<sum;
  44. }
  45.  
  46.  
  47.  
  48. return 0;
  49. }
  50.  
  51.  
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement