Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int x, k, n;
int main() {
scanf("%d %d %d", &x, &k, &n);
int f = (x / k) * k + k;
bool ok = false;
for(int i = f; i <= n; i += k) {
ok = true;
printf("%d ", i - x);
}
if(!ok)
puts("-1");
return 0;
}
Copy The Code &
Try With Live Editor
Input
10 1 10
Output
-1
Demonstration
Codeforcess Solution Two Bags of Potatoes,A. Two Bags of Potatoes ,C,C++, Java, Js and Python ,Two Bags of Potatoes,Codeforcess Solution