1 条题解
-
0
C++ :
#include <bits/stdc++.h> using namespace std; int main(){ int a[10000],x,g,s,b,q,i,r = 0,c = 0,n; int t[10000],k = 0; cin>>x>>n; for(i = 0;i < n;i++){ cin>>a[i]; g = a[i] % 10; s = a[i] / 10 % 10; b = a[i] / 100 % 10; q = a[i] / 1000; if(g + s + b + q == x){ t[k] = a[i]; r = r + t[k]; k++; } } sort(t,t+k); cout<<r<<" "<<k<<endl; for(i = 0;i < k;i++){ cout<<t[i]<<" "; } }
Python :
def swh(n): s=list(map(int,str(n))) return sum(s); m,n=list(map(int,input().split())) s1=list(map(int,input().split())) s2=[item for item in s1 if swh(item)==m] print(sum(s2),len(s2)) s2.sort() for item in s2: print(item,end=" ")
- 1
信息
- ID
- 2370
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- 5
- 标签
- 递交数
- 82
- 已通过
- 29
- 上传者