Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- # include<algorithm>
- # include <cstring>
- # include <stdio.h>
- using namespace std;
- int num_list[1000000];
- int main()
- {
- int t;
- scanf("%d",&t);
- while(t--)
- {
- int a,b,n;
- memset(num_list, 0, sizeof (num_list));
- scanf("%d%d%d",&a,&b,&n);
- int ans[1001];
- int i,j,k;
- ans[0] =1;
- printf("%s","1 ");
- num_list[0] = 1;
- for(i=1;i<n;i++)
- {
- int temp_num;
- for(j=0;j<i;j++)
- {
- temp_num = (a*ans[i-1]-b*ans[j]);
- if(temp_num>0)
- num_list[temp_num] = 1;
- temp_num = (a*ans[i-1]-b*ans[j]);
- if(temp_num>0)
- num_list[temp_num] = 1;
- }
- k=ans[i-1]+1;
- while(num_list[k]!=0)
- k++;
- num_list[k] = 1;
- ans[i] = k;
- printf("%d%s",ans[i]," ");
- }
- printf("\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment