10 条题解
-
1
#include<bits/stdc++.h> using namespace std; int a[10086],n,b,sum; int main() { cin>>n; for(int j=0; j<n; j++) { cin>>b; for(int i=0; i<=1000; i++) if(i==b)a[i]++; } for(int i=0; i<=1000; i++) if(a[i]!=0)sum++; cout<<sum<<endl; for(int i=0; i<=1000; i++) if(a[i]!=0)cout<<i<<" "; }
光速题解
-
0
C++
还得是桶排
#include <bits/stdc++.h> using namespace std; int main(){ int a[1010] = {0}; int n; int ans = 0; cin >> n; for(int i = 1; i <= n; i++) { int x; cin >> x; a[x] = 1; } for(int i = 0; i <= 1000; i++) { if(a[i]) { ans += 1; } } cout << ans << endl; for(int i = 0; i <= 1000; i++) { if(a[i]) { cout << i << " "; } } return 0; }
-
0
using namespace std; int main(){ int n,sum=0; cin>>n; int a[n+1],b[1001]; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=1000;i++) b[i]=0; for(int i=1;i<=n;i++) b[a[i]]++; for(int i=1;i<=1000;i++) if(b[i]!=0){ sum++; } cout<<sum<<endl; for(int i=1;i<=1000;i++) if(b[i]!=0) cout<<i<<" "; }
桶
-
0
#include<bits/stdc++.h> using namespace std; int a[1000000],b[10000000]={}; int main() { int n,k=0; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; } sort(a,a+n); for(int i=0;i<n-1;i++) { if(a[i]==a[i+1]) { b[i]=1; } } for(int i=0;i<n;i++) { if(b[i]==0)k++; } cout<<k<<endl; for(int i=0;i<n;i++) { // cout<<endl; // cout<<b[i]<<" "; if(b[i]==0) { cout<<a[i]<<" "; } } }
-
-1
- 1
信息
- ID
- 734
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- 递交数
- 666
- 已通过
- 313
- 上传者