Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- int arr[n];
- for(int i=0;i<n;i++)
- {
- cin>>arr[i];
- }
- int count=0;
- for(int j=0;j<n-1;j++)
- {
- if((arr[j]==1) and (arr[j+1]==2))
- {
- count+=3;
- }
- else
- if((arr[j]==2) and (arr[j+1]==1))
- {
- count+=3;
- }
- else
- if((arr[j]==1) and (arr[j+1]==3))
- {
- count+=4;
- }
- else
- if((arr[j]==3) and (arr[j+1]==1))
- {
- count+=4;
- }
- else
- if((arr[j]==2) and (arr[j+1]==3))
- {
- cout<<"Infinite\n";
- return 0;
- }
- else
- if((arr[j]==3) and (arr[j+1]==2))
- {
- cout<<"Infinite\n";
- return 0;
- }
- }
- cout<<"Finite\n"<<count;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement