Advertisement
islomiddin

Untitled

Dec 26th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import java.util.*;
  2. public class potato
  3. {
  4. public static void main(String[] args)
  5. {
  6. Scanner sc=new Scanner(System.in);
  7. int y=sc.nextInt();
  8. int k=sc.nextInt();
  9. int n=sc.nextInt();
  10. int b=n-y;
  11. int[] l=new int[b+1];
  12. int j=0;
  13. for(int i=0;i<b+1;i++)
  14. {
  15. l[i]=j;
  16. j++;
  17. }
  18. int count=0;
  19. for(int i=0;i<b;i++)
  20. {
  21. if((l[i]+y)<=n&&(l[i]+y)%k==0)
  22. count++;
  23. }
  24. int[] po=new int[(int)(b+1)];
  25. String str="";
  26. for(int i=0;i<b+1;i++)
  27. {
  28. if((l[i]+y)<=n&&(l[i]+y)%k==0)
  29. po[i]=l[i];
  30. }
  31. int yes=0;
  32. for(int i=0;i<b+1;i++)
  33. {
  34. if(po[i]!=0&&i!=0)
  35. {
  36. System.out.print(po[i]+" ");
  37. yes++;
  38. }
  39. }
  40. if(yes<count||yes==0)
  41. System.out.println(-1);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement