View Code of Problem 3571

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define mod 1e9+7
#define N 1000001
int a[N];
int cmcc(int x,int y)
{
        int i,j,flag,cnt=0;
        for(i=x;i<=y;i++)
        {
                flag=0;
                for(j=x;j!=i&&j<=y;j++)
                {
                        if(a[i]%a[j]==0)
                        {
                                flag=1;
                                break;
                        }
                }
                if(flag==0)
                        cnt++;
        }
        return cnt;
}
int main()
{
        int n,i,j;
        freopen("1001.in","r",stdin);
        int cnt;
        scanf("%d",&n);
                cnt=0;
                for(i=0;i<n;i++)
                scanf("%d",&a[i]);
                for(i=0;i<n;i++)
                        for(j=i;j<n;j++)
                {
                                cnt+=cmcc(i,j);
                }
                printf("%d\n",cnt%mod);
        return 0;
}

/*
Main.cc: In function 'int main()':
Main.cc:4:13: error: invalid operands of types 'int' and 'double' to binary 'operator%'
 #define mod 1e9+7
             ^
Main.cc:40:35: note: in expansion of macro 'mod'
                 printf("%d\n",cnt%mod);
                                   ^
*/

Double click to view unformatted code.


Back to problem 3571