Submission #1594233


Source Code Expand

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){

	LL N;
	int Q;
	cin >> N >> Q;
	vector<int> A(Q);
	for(int i=0;i<Q;++i){
		cin >> A[i];
	}
	
	set<LL> num;
	set<LL>::iterator itr,end;
	num.insert(1);//1は最後まで1
	for(int i=Q-1;i>=0;--i){
		itr = num.begin();
		end = num.end();
		set<LL> next;
		for(;itr!=end;++itr){
			LL now = *itr;
			if( now * A[i] <= N ){
				next.insert( now * A[i] );
			}
			if( now % A[i] != 0){
				next.insert( now );
			}
		}
		num = next;
	}

	LL ans = 0;
	itr = num.begin();
	end = num.end();
	for(;itr!=end;++itr){
		if( (*itr) <= N ){
			++ans;
		}else{
			break;
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Submission Info

Submission Time
Task B - Division 2
User akarin55
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1942 Byte
Status AC
Exec Time 36 ms
Memory 4992 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 25 / 25 75 / 75
Status
AC × 4
AC × 10
AC × 18
Set Name Test Cases
Sample sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt
Subtask1 sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, sub1_1.txt, sub1_2.txt, sub1_3.txt, sub1_4.txt, sub1_5.txt, sub1_6.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, sub1_1.txt, sub1_2.txt, sub1_3.txt, sub1_4.txt, sub1_5.txt, sub1_6.txt, sub2_1.txt, sub2_2.txt, sub2_3.txt, sub2_4.txt, sub2_5.txt, sub2_6.txt, sub2_7.txt, sub2_8.txt
Case Name Status Exec Time Memory
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt AC 1 ms 256 KB
sample_4.txt AC 1 ms 256 KB
sub1_1.txt AC 1 ms 256 KB
sub1_2.txt AC 1 ms 256 KB
sub1_3.txt AC 1 ms 256 KB
sub1_4.txt AC 1 ms 256 KB
sub1_5.txt AC 1 ms 256 KB
sub1_6.txt AC 1 ms 256 KB
sub2_1.txt AC 2 ms 384 KB
sub2_2.txt AC 3 ms 512 KB
sub2_3.txt AC 3 ms 512 KB
sub2_4.txt AC 2 ms 384 KB
sub2_5.txt AC 9 ms 1280 KB
sub2_6.txt AC 5 ms 1024 KB
sub2_7.txt AC 17 ms 2048 KB
sub2_8.txt AC 36 ms 4992 KB