Demo entry 6751485

hulk

   

Submitted by anonymous on Jun 23, 2018 at 22:48
Language: C++. Code size: 831 Bytes.

#include <bits/stdc++.h>

#define mod 1000000007


using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef long long int ll; 
class DivFreed2 {
    public:
    int count(int n, int k) {
         int f[100005][15];
		int sum =0 ; 
		 vvi div(100005);
		for(int i=1;i<=k;i++){
			for(int j=2*i ; j<=k ; j+=i){
				div[i].push_back(j);
			}
		}
		for(int i=1; i<=k ; i++){
			f[i][1] = 1;
		}
		sum = k;
		int newsum=k;
		for(int col=2 ; col<=n ; col++){
			int tmp=sum;
			newsum = 0;
			for(int row = 1; row<=k ; row++){
				for(int t = 0 ; t < (int)div[row].size() ; t++){
					tmp = (tmp - f[div[row][t]][col-1]+mod)%mod;
				}
				f[row][col] = (tmp+mod)%mod;
				tmp = sum;
				newsum =  (newsum+f[row][col])%mod;
			}
			sum = newsum;
		}
		return newsum;
    }
};

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).