371 条题解
-
0bnuyuan LV 3 @ 2016-05-14 15:39:08
var i,j,t,n,h:longint;
a:array[1..100]of longint;
begin
readln(n);
for i:=1 to n do
read(a[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if(a[i]=a[j])and(a[i]<>0)and(a[j]<>0)
then begin a[j]:=0; t:=t+1; end;
for i:=1 to n-1 do
for j:=i+1 to n do
if(a[i]>a[j])
then begin
h:=a[i];
a[i]:=a[j];
a[j]:=h;
end;
writeln(n-t);
for i:=1 to n do
if(a[i]<>0)
then write(a[i],' ');
end. -
02016-05-01 19:06:52@
var i,j,t,n,h:longint;
a:array[1..100]of longint;
begin
readln(n);
for i:=1 to n do
read(a[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if(a[i]=a[j])and(a[i]<>0)and(a[j]<>0)
then begin a[j]:=0; t:=t+1; end;
for i:=1 to n-1 do
for j:=i+1 to n do
if(a[i]>a[j])
then begin
h:=a[i];
a[i]:=a[j];
a[j]:=h;
end;
writeln(n-t);
for i:=1 to n do
if(a[i]<>0)
then write(a[i],' ');
end. -
02016-04-20 19:21:53@
开布尔型有就true,最后判断输出
var
a:array [1..1000] of boolean;
n,i,k,x:integer;
begin
readln(n);
fillchar(a,sizeof(a),false);
for i:=1 to n do
begin
read(k);
a[k]:=true;
end;
for i:=1 to 1000 do
if a[i] then x:=x+1;
writeln(x);
for i:=1 to 1000 do
if a[i] then write(i,' ');
end. -
02016-03-24 19:46:26@
Java TreeSet分分钟解决问题
```java
import java.util.*;public class Main {
public static void main(String[] args) {
Set<Integer> sets = new TreeSet<Integer>();
Scanner scanner = new Scanner(System.in);
int n;
n = scanner.nextInt();
for (int x = 0; x != n; x++) {
sets.add(scanner.nextInt());
}
System.out.println(sets.size());
String data = sets.toString();
System.out.println(data.substring(1, data.length() - 1).replace(", ", " "));
scanner.close();
}
}
``` -
02016-03-08 17:19:13@
#include<iostream>
using namespace std;
int N;
int i;
int x;
int a[1001];
int sum;
int main()
{
cin>>N;
for(i=0;i<N;i++)
{
cin>>x;
a[x]++;
}
for(i=0;i<=1000;i++)
{
if(a[i]>0)
sum++;
}
cout<<sum<<endl;
for(i=0;i<=1000;i++)
{
if(a[i]>0)
cout<<i<<" ";
}
return 0;
} -
02016-03-08 17:16:41@
include<iostream>
using namespace std;
int n,a[1002];
int t,count;
int main()
{
//freopen("p.in","r",stdin);
//freopen("p.out","w",stdout);
cin>>n;
for(int i=0;i<n;i++) { cin>>t;
a[t]++;
}
for(int i=0;i<=1000;i++)
{
if (a[i]>0) count++;
}
cout<<count<<endl; for(int i=0;i<=1000;i++) { if (a[i]>0) cout<<i<<" ";
}
return 0;
}题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题
题题题题题题题题题题题题题题题题题题题题题题题题题题题题水水水水题题题题题
题题题题题题题题题题题题题题题题题题题题题题题题水水水水水水水水水题题题题
题题题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题
题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题题题
题题题题题题题题题题题水水水水题水水水水水水水水水水水题题题题题题题题题题
题题题题题题题题水水水水水水水题水水水题题水水水水水题题题题题题题题题题题
题题题水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
题水水水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
题水水水水水水水水水水水水题题题题题题题水水水水水水水水水水水题题题题题题
题水水水水水水水水水水水水题题题题题题水水水水水水水水水水水水水水题题题题
题题水水水水水水水水水水题题题题题水水水水水水题题题水水水水水水水题题题题
题题题题题题题题水水水水题题题题题水水水水题题题题题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水题题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水题题水水水水题题水水水水水题题题题题
题题水水题题题水水水水水题题题题水水水题题水水水题题题水水水水水题题题题题
题题水水水水水水水水水水题题题题题水水题题水水题题题题水水水水水题题题题题
题题题水水水水水水水水水题题题题题题题题水水水题题题题水水水水题题题题题题
题题题题题水水水水水水水题题题题题题题题水水水题水水水水题题题题题题题题题
题题题题题题水水水水水水题题题题题题题水水水水题题水水水水题题题题题题题题
题题题题题题题题题水水水题题题题题题水水水水水题题题水水水水水水水题题题题
题题题题题题题题题题题题题题题题水水水水水水题题题题题水水水水水水题题题题
题题题题题题题题题题题题题题题水水水水水水题题题题题题水水水水水水水题题题
题题题题题题题题题题题题题题水水水水水题题题题题题题题题水水水水水水题题题
题题题题题题题题题题题题题水水水水水题题题题题题题题题题题水水水水题题题题
题题题题题题题题题题题题水水水题题题题题题题题题题题题题题题水水水题题题题
题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题 -
02016-03-08 16:58:58@
include<iostream> include<cmath> include<cstdio> include<cstdlib>
using namespace std;
int main()
{
int n,a[1010];
cin >>n;
for (int i=1 ; i<=n ; ++i )
cin >>a[i];
for (int i=1 ; i<=n ; ++i )
for (int j=i+1 ; j<=n ; ++j )
if (a[i]>a[j])
{
int u=a[i];
a[i]=a[j];
a[j]=u;}
a[0]=0;
int sum=0;
for (int i=1 ; i<=n ; ++i )
if(a[i]!=a[i-1])
sum++;
cout<<sum<<endl;
for (int i=1 ; i<=n ; ++i )
if(a[i]!=a[i-1])cout << a[i] << " ";
return 0;
} -
02016-03-08 16:49:30@
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main()
{
int n,a[1010];
cin >>n;
for (int i=1 ; i<=n ; ++i )
cin >>a[i];
for (int i=1 ; i<=n ; ++i )
for (int j=i+1 ; j<=n ; ++j )
if (a[i]>a[j])
{
int u=a[i];
a[i]=a[j];
a[j]=u;}
a[0]=0;
int sum=0;
for (int i=1 ; i<=n ; ++i )
if(a[i]!=a[i-1])
sum++;
cout<<sum<<endl;
for (int i=1 ; i<=n ; ++i )
if(a[i]!=a[i-1])cout << a[i] << " ";
return 0;
} -
02016-03-08 07:30:24@
#include<iostream>
#include<string.h>
using namespace std;
int main(){
bool hash[1000];
memset(hash,false,1000);
int temp;
unsigned int count;
unsigned int m_count = 0;
cin>>count;
while(cin>>temp){
if(!hash[temp-1]){
hash[temp-1] = true;
m_count++;
}
}
cout<<m_count<<endl;
for(int i = 0; i < 1000; ++i){
if(hash[i])
cout<<(i+1)<<' ';
}
return 0;
} -
02016-03-02 22:19:25@
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;int main()
{
int n,m=0;
cin>>n;
int a[101];
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])
{a[i]=0;m++;}
sort(a,a+n);
cout<<n-m<<endl;
for(int i=m;i<n-1;i++)
cout<<a[i]<<' ';
cout<<a[n-1];
return 0;
} -
02016-02-21 11:44:53@
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader( System.in))); List<Integer> list = new ArrayList<Integer>(); sc.nextInt(); while (sc.hasNextInt()) list.add(sc.nextInt()); for (int i = 0; i < list.size() - 1; i++) for (int j = list.size() - 1; j > i; j--) if (list.get(j).equals(list.get(i))) list.remove(j); Integer[] num = list.toArray(new Integer[0]); Arrays.sort(num); System.out.println(list.size()); for (int i : num) System.out.print(i + " "); } }
-
02016-02-20 15:35:30@
/* *********************************************** Author :guanjun Created Time :2016/2/20 15:31:34 File Name :vijosp1316.cpp ************************************************ */ #include <iostream> #include <cstring> #include <cstdlib> #include <stdio.h> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <iomanip> #include <list> #include <deque> #include <stack> #define ull unsigned long long #define ll long long #define mod 90001 #define INF 0x3f3f3f3f #define maxn 10000+10 #define cle(a) memset(a,0,sizeof(a)) const ull inf = 1LL << 61; const double eps=1e-5; using namespace std; priority_queue<int,vector<int>,greater<int> >pq; struct Node{ int x,y; }; struct cmp{ bool operator()(Node a,Node b){ if(a.x==b.x) return a.y> b.y; return a.x>b.x; } }; bool cmp(int a,int b){ return a>b; } int a[110]; int main() { #ifndef ONLINE_JUDGE //freopen("in.txt","r",stdin); #endif //freopen("out.txt","w",stdout); int vis[1001]; cle(vis); int n,x; cin>>n; int num=0; for(int i=1;i<=n;i++){ cin>>x; if(!vis[x]){ vis[x]=1; a[num++]=x; } } sort(a,a+num); cout<<num<<endl; for(int i=0;i<num;i++){ cout<<a[i]<<" "; } return 0; }
-
02016-01-24 21:05:23@
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a[101],n,x,t,f[101];
cin>>n;
for (int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
x=a[0];t=1;
for (int i=1;i<n;i++)
if (x!=a[i])
{
t++;
f[t]=x;
x=a[i];
}
f[++t]=x;
cout<<t-1<<endl;
for (int i=2;i<=t;i++)
cout<<f[i]<<" ";
}
题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题
题题题题题题题题题题题题题题题题题题题题题题题题题题题题水水水水题题题题题
题题题题题题题题题题题题题题题题题题题题题题题题水水水水水水水水水题题题题
题题题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题
题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题题题
题题题题题题题题题题题水水水水题水水水水水水水水水水水题题题题题题题题题题
题题题题题题题题水水水水水水水题水水水题题水水水水水题题题题题题题题题题题
题题题水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
题水水水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
题水水水水水水水水水水水水题题题题题题题水水水水水水水水水水水题题题题题题
题水水水水水水水水水水水水题题题题题题水水水水水水水水水水水水水水题题题题
题题水水水水水水水水水水题题题题题水水水水水水题题题水水水水水水水题题题题
题题题题题题题题水水水水题题题题题水水水水题题题题题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水题题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水题题水水水水题题水水水水水题题题题题
题题水水题题题水水水水水题题题题水水水题题水水水题题题水水水水水题题题题题
题题水水水水水水水水水水题题题题题水水题题水水题题题题水水水水水题题题题题
题题题水水水水水水水水水题题题题题题题题水水水题题题题水水水水题题题题题题
题题题题题水水水水水水水题题题题题题题题水水水题水水水水题题题题题题题题题
题题题题题题水水水水水水题题题题题题题水水水水题题水水水水题题题题题题题题
题题题题题题题题题水水水题题题题题题水水水水水题题题水水水水水水水题题题题
题题题题题题题题题题题题题题题题水水水水水水题题题题题水水水水水水题题题题
题题题题题题题题题题题题题题题水水水水水水题题题题题题水水水水水水水题题题
题题题题题题题题题题题题题题水水水水水题题题题题题题题题水水水水水水题题题
题题题题题题题题题题题题题水水水水水题题题题题题题题题题题水水水水题题题题
题题题题题题题题题题题题水水水题题题题题题题题题题题题题题题水水水题题题题
题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题 -
02016-01-15 19:14:45@
###Block Code
//桶排序即可
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int i,j,n,t,q,sum=0;
cin>>n;
int shu[n],a[5000];
memset(a,0,sizeof(a));
for (i=0;i<n;i++)
{
cin>>shu[i];
a[shu[i]]++;
}
for (i=0;i<=1000;i++)
{
if (a[i]>0) sum++;
}
cout<<sum<<endl;
for (i=0;i<=1000;i++)
{
if (a[i]>0)
cout<<i<<" ";
}
} -
02015-11-25 18:52:10@
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>using namespace std;
int main()
{
int n,a[1010];
cin >>n;for (int i=1 ; i<=n ; ++i )
cin >>a[i];
for (int i=1 ; i<=n ; ++i )
for (int j=i+1 ; j<=n ; ++j )
if (a[i]>a[j]){
int u=a[i];
a[i]=a[j];
a[j]=u;}
a[0]=0;
int sum=0;
for (int i=1 ; i<=n ; ++i )
if(a[i]!=a[i-1])
sum++;
cout<<sum<<endl;
for (int i=1 ; i<=n ; ++i )
if(a[i]!=a[i-1])cout << a[i] << " ";
return 0;
} -
02015-10-29 20:02:45@
**P1316明明的随机数
Accepted记录信息
评测状态 Accepted
题目 P1316 明明的随机数
递交时间 2015-10-06 16:20:05
代码语言 Pascal
评测机 VijosEx
消耗时间 62 ms
消耗内存 808 KiB
评测时间 2015-10-06 16:20:06评测结果
编译成功Free Pascal Compiler version 2.6.4 [2014/03/06] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling foo.pas
foo.pas(2,11) Note: Local variable "l" not used
Linking foo.exe
21 lines compiled, 0.1 sec , 28320 bytes code, 1628 bytes data
1 note(s) issued测试数据 #0: Accepted, time = 15 ms, mem = 804 KiB, score = 10
测试数据 #1: Accepted, time = 8 ms, mem = 808 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 804 KiB, score = 10
测试数据 #3: Accepted, time = 15 ms, mem = 808 KiB, score = 10
测试数据 #4: Accepted, time = 9 ms, mem = 804 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 804 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 808 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 804 KiB, score = 10
测试数据 #8: Accepted, time = 15 ms, mem = 808 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 808 KiB, score = 10
Accepted, time = 62 ms, mem = 808 KiB, score = 100
代码
var a:array[1..10000]of longint;
i,j,k,l,n,s:longint;
begin
read(n);s:=0;
for i:=1 to n do
read(a[i]);
for i:=1 to n-1 do
for j:=n-1 downto i do
begin
if a[j]>a[j+1] then
begin
k:=a[j];
a[j]:=a[j+1];
a[j+1]:=k;
end;
if a[j]=a[j+1] then begin a[j]:=0; s:=s+1; end;
end;
writeln(n-s);
for i:=1 to n do
if a[i]<>0 then write(a[i],' ');
end.** -
02015-10-24 21:19:02@
测试数据 #0: Accepted, time = 0 ms, mem = 772 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 776 KiB, score = 10
测试数据 #2: Accepted, time = 19 ms, mem = 772 KiB, score = 10
测试数据 #3: Accepted, time = 19 ms, mem = 776 KiB, score = 10
测试数据 #4: Accepted, time = 4 ms, mem = 772 KiB, score = 10
测试数据 #5: Accepted, time = 15 ms, mem = 772 KiB, score = 10
测试数据 #6: Accepted, time = 1 ms, mem = 772 KiB, score = 10
测试数据 #7: Accepted, time = 1 ms, mem = 776 KiB, score = 10
测试数据 #8: Accepted, time = 13 ms, mem = 772 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 772 KiB, score = 10
Accepted, time = 72 ms, mem = 776 KiB, score = 100
代码
program random;
var
n,i,j,s,x:integer;
a:array[1..300] of integer;
begin
readln(n);
s:=0; x:=0;
for i:=1 to n do
read(a[i]);for i:=1 to n do
for j:=i+1 to n do
if a[i]=a[j] then a[j]:=0;for i:=1 to n-1 do
for j:=i+1 to n do
if a[i] > a[j] then
begin
s:=a[i]; a[i]:=a[j]; a[j]:=s;
end;for i:=1 to n do
if a[i]=0 then inc(x);writeln(n-x);
for i:=1 to n do
if a[i] <> 0 then
write(a[i],' ');
end. -
02015-10-13 20:05:38@
var a:array[1..100000] of boolean;
n,i,j:longint;
begin
read(n);
for i:=1 to n do
begin read(j);
a[j]:=true;
end;
j:=0;
for i:=1 to 100000 do
if a[i]
then j:=j+1;
writeln(j);
for i:=1 to 100000 do
if a[i]
then write(i,' ');
end. -
02015-09-26 09:59:36@
#include<iostream>
#include<set>
#include<iterator>
using namespace std;
set<int> m;
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
m.insert(x);
}
int len=m.size();
cout<<len<<endl;
set<int>::iterator it;
it=m.begin();
cout<<(*it);
it++;
for(;it!=m.end();it++)
cout<<" "<<(*it);
cout<<endl;
return 0;
}c++的set就是好用....程序短到任性!
-
02015-09-18 09:37:40@
program px;
var t:array[0..1000] of boolean;
x:array[0..100] of integer;
n:integer;i,j:integer;
nx:integer;
ny:integer;p:integer;nz:integer;
procedure px;
begin
for i:=1 to n-1 do
for j:=i+1 to n do
if x[i]>x[j] then
begin
p:=x[i];
x[i]:=x[j];
x[j]:=p;
end;
end;begin
readln(n);
ny:=0;
nz:=0;
for i:=1 to n do t[i]:=false;
for i:=1 to n do
begin
read(nx);
if t[nx]=true then nz:=nz+1;
if t[nx]=false then
begin
t[nx]:=true;
x[i-nz]:=nx;
ny:=ny+1;
end;
end;
n:=ny;
px;
writeln(n);
for i:= 1 to n do write(x[i],' ');
end.