Advertisement
jakaria_hossain

codeforce - Nearest Interesting Number

Jun 26th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
  4. typedef long long ll;
  5. int main()
  6. {
  7. fast();
  8. int n,sum=0,x;
  9. cin>>n;
  10. x=n;
  11. while(n>0)
  12. {
  13. sum+=(n%10);
  14. n/=10;
  15. }
  16. //cout<<sum<<endl;
  17. if(sum%4==0)
  18. cout<<x<<endl;
  19. else
  20. {
  21. while(1)
  22. {
  23. x+=1;
  24. n=x;
  25. sum=0;
  26. while(n>0)
  27. {
  28. sum+=(n%10);
  29. n/=10;
  30. }
  31. //cout<<sum<<endl;
  32. if(sum%4==0)
  33. {
  34. cout<<x<<endl;
  35. return 0;
  36. }
  37.  
  38. }
  39.  
  40. }
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement