Răspuns:
#include <iostream>
using namespace std;
int main()
{
int x,s,n;
cin>>x;
s=0;
do
{
cin>>n;
if(n%x==0)
s=s+n;
}
while(n!=0);
cout<<s;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int x,s,n,c=-1;
cin>>x;
s=0;
while(c!=0)
{
cin>>n;
if(n%x==0)
s=s+n;
c=n;
}
cout<<s;
return 0;
}