Submission #1872171
Source Code Expand
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// _oo0oo_ //
// o8888888o //
// 88" . "88 ------ hzt1 //
// (| -_- |) //
// 0\ = /0 //
// ___/`---'\___ //
// .' \| |// '. //
// / \||| : |||// \ //
// / _||||| -:- |||||- \ //
// | | \ - /// | | //
// | \_| ''\---/'' |_/ | //
// \ .-\__ '-' ___/-. / //
// ___'. .' /--.--\ `. .'___ //
// ."" '< `.___\_<|>_/___.' >' "". //
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
// \ \ `_. \_ __\ /__ _/ .-` / / //
// =====`-.____`.___ \_____/___.-`___.-'===== //
// `=---=' //
// //
// //
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// //
// God-He Bless All. //
// This Code Will Never Explode. //
// //
// //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
if(head==tail) {
int l=fread(buffer,1,Size,stdin);
tail=(head=buffer)+l;
}
if(head==tail) return -1;
return *head++;
}
typedef long long ll;
inline ll read() {
ll x=0,f=1;char c=Getchar();
for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
return x*f;
}
typedef pair<int,int> pii;
const int maxn=100010;
int n,m,top;
ll ans[maxn],A[maxn],cnt[maxn];
#define S Size
char pf[S],*o1=pf,*o2=pf+S;
#define ot(x) (o1==o2?fwrite(pf,1,S,stdout),*(o1=pf)++=x:*o1++=x)
inline void print(ll x){static char s[20],*b;b=s;if(!x)*b++=48;for(;x;*b++=x%10+48,x/=10);for(;b--!=s;ot(*b));}
int main() {
n=read();m=read();
A[++top]=n;
rep(i,1,m) {
ll x=read();
while(top&&A[top]>=x) top--;
A[++top]=x;
}
cnt[top]=1;
dwn(i,top,1) {
ll x=A[i];int t;
while(t=upper_bound(A,A+i,x)-A-1) {
cnt[t]+=(ll)cnt[i]*(x/A[t]);
x%=A[t];
}
ans[x]+=cnt[i];
}
dwn(i,n-1,1) ans[i]+=ans[i+1];
rep(i,1,n) print(ans[i]),ot('\n');
fwrite(pf,1,o1-pf,stdout);
return 0;
}
Submission Info
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
1400 / 1400 |
Status |
|
|
Set Name |
Test Cases |
Sample |
s1.txt, s2.txt |
All |
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, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, s1.txt, s2.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
11 ms |
2304 KB |
02.txt |
AC |
12 ms |
2432 KB |
03.txt |
AC |
12 ms |
2432 KB |
04.txt |
AC |
12 ms |
2432 KB |
05.txt |
AC |
12 ms |
2432 KB |
06.txt |
AC |
21 ms |
3968 KB |
07.txt |
AC |
24 ms |
4096 KB |
08.txt |
AC |
23 ms |
4096 KB |
09.txt |
AC |
25 ms |
3968 KB |
10.txt |
AC |
22 ms |
3968 KB |
11.txt |
AC |
20 ms |
4096 KB |
12.txt |
AC |
24 ms |
3968 KB |
13.txt |
AC |
25 ms |
4096 KB |
14.txt |
AC |
21 ms |
3968 KB |
15.txt |
AC |
20 ms |
3968 KB |
16.txt |
AC |
22 ms |
3968 KB |
17.txt |
AC |
23 ms |
4096 KB |
18.txt |
AC |
22 ms |
3968 KB |
19.txt |
AC |
19 ms |
3968 KB |
20.txt |
AC |
23 ms |
4096 KB |
21.txt |
AC |
37 ms |
2816 KB |
22.txt |
AC |
20 ms |
3712 KB |
23.txt |
AC |
28 ms |
3968 KB |
24.txt |
AC |
15 ms |
3968 KB |
25.txt |
AC |
15 ms |
3840 KB |
26.txt |
AC |
9 ms |
2816 KB |
27.txt |
AC |
3 ms |
1280 KB |
28.txt |
AC |
3 ms |
1280 KB |
29.txt |
AC |
3 ms |
1280 KB |
30.txt |
AC |
3 ms |
1280 KB |
31.txt |
AC |
1 ms |
128 KB |
32.txt |
AC |
2 ms |
1152 KB |
33.txt |
AC |
1 ms |
128 KB |
34.txt |
AC |
8 ms |
2432 KB |
35.txt |
AC |
1 ms |
128 KB |
36.txt |
AC |
1 ms |
128 KB |
s1.txt |
AC |
1 ms |
128 KB |
s2.txt |
AC |
1 ms |
128 KB |