Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <algorithm>
- #include <cstdlib>
- #include <limits.h>
- #include <string>
- #define ll long long
- using namespace std;
- void Fast_IO();
- void Rofyda_Elghadban(){
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- int main()
- { Rofyda_Elghadban();
- //Fast_IO();
- //freopen("input.txt","r",stdin);
- //freopen("output.txt","r",stdout);
- ll a,b,x,sum=0;
- cin>>a>>b>>x;
- if(b>=a){
- if(b==x){
- cout<<b;
- }else{
- for(ll i=a;i<=b;i++){
- if(i%x==0){
- sum+=i;
- }
- }cout<<sum;
- }
- }else if(b<a){
- for(int i=b;i<=a;i++){
- if(i%x==0){
- sum+=i;
- }
- }cout<<sum;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement