Advertisement
islomiddin

Untitled

Dec 26th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 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 j=0;
  12. boolean gh=false;
  13. if(y<n)
  14. {
  15. int[] l=new int[b+1];
  16. for(int i=0;i<b+1;i++)
  17. {
  18. l[i]=j;
  19. j++;
  20. }
  21. int count=0;
  22. for(int i=0;i<b;i++)
  23. {
  24. if((l[i]+y)<=n&&(l[i]+y)%k==0)
  25. count++;
  26. }
  27. int[] po=new int[(int)(b+1)];
  28. String str="";
  29. for(int i=0;i<b+1;i++)
  30. {
  31. if((l[i]+y)<=n&&(l[i]+y)%k==0)
  32. po[i]=l[i];
  33. }
  34. int yes=0;
  35. for(int i=0;i<b+1;i++)
  36. {
  37. if(po[i]!=0&&i!=0)
  38. {
  39. System.out.print(po[i]+" ");
  40. yes++;
  41. }
  42. }
  43. if(yes<count||yes==0)
  44. System.out.println(-1);
  45. gh=true;
  46. }
  47. else if(!gh)
  48. System.out.println(-1);
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement