Submission #1686348
Source Code Expand
//2017-10-15
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define N (100000+5)
LL a[N], cnt[N], suf[N], ans[N];
int main(){
int rn, n, Q, an = 0;
LL rt, len, cs;
scanf("%d%d", &n, &Q);
a[++an] = 1ll * n;
For(i, 1, Q){
scanf("%lld", &rt);
while(an && a[an] >= rt) --an;
a[++an] = rt;
}
rn = n; n = min((int)a[1], n);
cnt[an] = 1;
Forr(i, an, 2){
len = a[i];
while(len >= a[1]){
int tp = lower_bound(a+1, a+i, len) - a - 1;
cnt[tp] += (cs = len / a[tp]) * cnt[i];
len -= cs * a[tp];
}
suf[len] += cnt[i];
}
LL sum = 0;
Forr(i, n, 1) sum += suf[i], ans[i] = cnt[1] + sum;
For(i, 1, rn) printf("%lld\n", ans[i]);
return 0;
}
Submission Info
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:25:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &Q);
^
./Main.cpp:29:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &rt);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
29 ms |
2304 KB |
02.txt |
AC |
29 ms |
2432 KB |
03.txt |
AC |
29 ms |
2432 KB |
04.txt |
AC |
29 ms |
2432 KB |
05.txt |
AC |
29 ms |
2432 KB |
06.txt |
AC |
38 ms |
4736 KB |
07.txt |
AC |
40 ms |
4864 KB |
08.txt |
AC |
40 ms |
4864 KB |
09.txt |
AC |
42 ms |
4736 KB |
10.txt |
AC |
39 ms |
4736 KB |
11.txt |
AC |
37 ms |
4864 KB |
12.txt |
AC |
41 ms |
4736 KB |
13.txt |
AC |
42 ms |
4864 KB |
14.txt |
AC |
38 ms |
4736 KB |
15.txt |
AC |
37 ms |
4736 KB |
16.txt |
AC |
39 ms |
4736 KB |
17.txt |
AC |
40 ms |
4864 KB |
18.txt |
AC |
38 ms |
4736 KB |
19.txt |
AC |
36 ms |
4736 KB |
20.txt |
AC |
40 ms |
4864 KB |
21.txt |
RE |
113 ms |
1024 KB |
22.txt |
AC |
36 ms |
4480 KB |
23.txt |
AC |
46 ms |
3968 KB |
24.txt |
AC |
29 ms |
4096 KB |
25.txt |
AC |
29 ms |
3840 KB |
26.txt |
AC |
25 ms |
2048 KB |
27.txt |
AC |
18 ms |
384 KB |
28.txt |
AC |
19 ms |
1280 KB |
29.txt |
AC |
19 ms |
1280 KB |
30.txt |
AC |
19 ms |
1280 KB |
31.txt |
AC |
1 ms |
256 KB |
32.txt |
AC |
9 ms |
1280 KB |
33.txt |
AC |
1 ms |
256 KB |
34.txt |
AC |
12 ms |
2560 KB |
35.txt |
AC |
1 ms |
256 KB |
36.txt |
AC |
1 ms |
256 KB |
s1.txt |
AC |
1 ms |
256 KB |
s2.txt |
AC |
1 ms |
256 KB |