Guest User

Untitled

a guest
Feb 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. # include <iostream>
  2. # include<algorithm>
  3. # include <cstring>
  4. # include <stdio.h>
  5. using namespace std;
  6.  
  7. int num_list[1000000];
  8.  
  9. int main()
  10. {
  11.  
  12. int t;
  13. scanf("%d",&t);
  14.  
  15.  
  16.  
  17. while(t--)
  18.  
  19. {
  20.  
  21. int a,b,n;
  22. memset(num_list, 0, sizeof (num_list));
  23.  
  24. scanf("%d%d%d",&a,&b,&n);
  25.  
  26. int ans[1001];
  27.  
  28. int i,j,k;
  29. ans[0] =1;
  30. printf("%s","1 ");
  31.  
  32.  
  33. num_list[0] = 1;
  34. for(i=1;i<n;i++)
  35. {
  36. int temp_num;
  37. for(j=0;j<i;j++)
  38. {
  39.  
  40. temp_num = (a*ans[i-1]-b*ans[j]);
  41. if(temp_num>0)
  42. num_list[temp_num] = 1;
  43.  
  44.  
  45. temp_num = (a*ans[i-1]-b*ans[j]);
  46. if(temp_num>0)
  47. num_list[temp_num] = 1;
  48.  
  49.  
  50.  
  51.  
  52. }
  53.  
  54.  
  55. k=ans[i-1]+1;
  56. while(num_list[k]!=0)
  57. k++;
  58.  
  59.  
  60. num_list[k] = 1;
  61. ans[i] = k;
  62. printf("%d%s",ans[i]," ");
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. }
  71. printf("\n");
  72.  
  73.  
  74. }
  75.  
  76. return 0;
  77.  
  78.  
  79. }
Add Comment
Please, Sign In to add comment