forked from volzkzg/sgu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path140.cpp
57 lines (51 loc) · 1.01 KB
/
140.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <fstream>
#include <algorithm>
#define rep(i,j,k) for (int i=j;i<=k;++i)
#define rrep(i,j,k) for (int i=j;i>=k;--i)
using namespace std;
int n,p,a,b;
short prev[10001],ans[101],posi[10001];
bool f[10001],ff[10001];
int main()
{
ios::sync_with_stdio(false);
memset(f,false,sizeof(f));
cin >> n >> b >> p;
f[0] = true;
rep(i,1,n)
{
cin >> a;
rep(j,0,b-1) ff[j] = f[j];
rep(j,0,b-1)
if (ff[j])
{
int pos,last=j;
pos=last+a;pos%=b;
while (!ff[pos])
{
f[pos] = true;
posi[pos] = i;prev[pos] = last;
last = pos;pos += a,pos%=b;
}
}
}
int re = p%b;
if (f[re])
{
cout << "YES" << endl;
while (re!=0)
{
ans[posi[re]]++;
re = prev[re];
}
rep(i,1,n-1) cout << ans[i] << " ";
cout << ans[n] << endl;
}
else
cout << "NO" << endl;
}