【AWC003】 C 题解

· · 题解

思路分析

依次枚举找出所有能 K 整除的数的和即可。

code

#include<bits/stdc++.h>
using namespace std;
long long n,k,sum,x;
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x%k==0)sum+=x;
    }
    cout<<sum;
    return 0;
}