You are on page 1of 3

Chip It!

Problem code: TGPA04 Submit All Submissions The students of IIST are developing their own satellite. So the OBC (OnBoard Computer) team being the most competent of all has been able to design a new 8-bit microprocessor which they plan to name EGSYS-1. Although being very proficient at their work, they are after all students. Thus there are many errors (failures) which occur in the microprocessor based upon various distinct factors. The testing team simulated the failures and found to their surprise that each of the failures occur at definite intervals which don't share any common factor other than 1. They have found the time at which each of the failures occurred last. They also say that when all the failures occur simultaneously the EGSYS-1 will burn off. They want you to predict that time.

Input Format
The first line contains the number of test cases, t. Each of the following t test case has the following format: 1. The first line contains an integer n indicating the number of distinct failures that occur in EGSYS-1. 2. The second line contains n integers (v1 v2 v3 vn) indicating the intervals (in ns) at which each of the failures occur. 3. The third line contains n (A1 A2 A3 An) integers separated by spaces indicating the last time in nano secs that each error occurred.

Output Format
For each test case, the time (in ns) at which the processor fails.
Sample Input: 1 3 345

5 7 11 Sample Output: 368

Submit Date: 2010-02-26 Time limit: 2s Source limit:50000 Languages: C C++ 4.3.2
#include<iostream.h> #include<conio.h> #include<stdio.h> void main() { clock_t start, end; long int a1[100],a2[100],a3[100],n,m,a,b,c,d,e,s; clrscr(); cout<<"Enter the number of test cases less then 10"<<endl; cin>>a; for(n=1;n<=a;n++) { cout<<"\nEnter number of errors"<<endl; cin>>c; for(b=0;b<c;b++) cin>>a1[b]; for(b=0;b<c;b++) cin>>a2[b]; e=a1[0]; for(m=0;m<(c-1);m++) { if(a1[m]<a1[m+1]) e=a1[m]; } for(b=e;b>0;b++) { for(m=0;m<c;m++) a3[m]=b-a1[m]; for(m=0;m<c;m++) a3[m]=a3[m]%a2[m]; s=0; for(m=0;m<c;m++) { if(a3[m]==0) s=s+1; } if(s==m)

break; } cout<<b; } getch(); }

You might also like