Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream fin("pdi.in");
- ofstream fout("pdi.out");
- int euclid(int a, int b)
- {
- int c;
- while(b)
- {
- c=a%b;
- a=b;
- b=c;
- }
- return a;
- }
- int nr, vec[100000], lung[1000];
- int main()
- {
- fin>>nr;
- for(int index=0; index<nr; index++)
- {
- fin>>vec[index];
- }
- for(int index=0; index<nr; index++)
- {
- lung[index]=1;
- for(int jndex=0; jndex<index; jndex++)
- if(euclid(vec[index], vec[jndex])!=1/* && lung[jndex]+1>lung[index]*/)
- lung[index]=max(lung[index], lung[jndex]+1);
- }
- fout<<lung[nr-1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement