Submission #2006886


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  ll a,b;
  cin>>a>>b;
  int n=b-a+1;
  ll dp[40][1<<11]={};
  dp[0][0]=1;
 
  int prime[11]={2,3,5,7,11,13,17,19,23,29,31};//11
 
  rep(i,n){
 	int b=0;
    ll tmp=a+i;
 
    rep(j,11)if(tmp%prime[j]==0)b|=1<<j;
 
    rep(j,1<<11){
      dp[i+1][j]+=dp[i][j];
      if((j&b)==0)dp[i+1][j|b]+=dp[i][j];
    }
  }
 
  ll ans=0;
  rep(i,1<<11)ans+=dp[n][i];
  cout<<ans<<endl;
}

Submission Info

Submission Time
Task C - すぬけそだて――ごはん――
User latte0119
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1058 Byte
Status
Exec Time 2 ms
Memory 896 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 400 / 400 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 1 ms 896 KB
02.txt 2 ms 896 KB
03.txt 2 ms 896 KB
04.txt 2 ms 896 KB
05.txt 2 ms 896 KB
06.txt 2 ms 896 KB
07.txt 2 ms 896 KB
08.txt 2 ms 896 KB
09.txt 2 ms 896 KB
10.txt 2 ms 896 KB
11.txt 2 ms 896 KB
12.txt 2 ms 896 KB
13.txt 2 ms 896 KB
14.txt 2 ms 896 KB
15.txt 2 ms 896 KB
s1.txt 2 ms 896 KB
s2.txt 2 ms 896 KB
s3.txt 2 ms 896 KB