245 条题解
-
2VIRUS LV 8 @ 2016-07-17 21:11:57
这题水主要是因为“如果A的名单里面有B,B的名单里面也一定有A”,所以说只要一个人的名单里的人数大于k,那么答案就加一。
-
22016-04-01 09:47:18@
根据输入建一张无向图,维护每个顶点的度和邻接点。先扫一遍顶点,将度小于k的点加入队列(待删除),然后依次处理队列中的每个点,对每个点,将它的邻接点的度减1,如果邻接点的度变得小于k了,把该邻接点也加入队列。
-
12021-10-10 09:46:28@
简单**模拟**即可
CODE
#include <iostream> using namespace std; int main(){ int n, k; cin >> n >> k; unsigned long long ans = 0; for(int i=1; i<=n; i++){ int count = 0, tmp; while(cin >> tmp && tmp != 0){ count++; } if(count >= k) ans++; } cout << ans << endl; return 0; }
-
12021-02-05 09:40:04@
这是一道比较基础的图的遍历。
思路 : 把图遍历一遍,统计有几个人愿意和k个或以上的人交流
代码 :#include<bits/stdc++.h>//万能头文件 using namespace std; struct go{ int to, next; }edge[100001];//前向星存边 int Head[100001], n, k, a, cnt, cnt1, ans; void add(int xx, int yy); int main() { scanf("%d%d", &n, &k);//输入 for (int i = 1; i <= n; i++) { Head[i] = -1; while (true) { scanf("%d", &a); if (a == 0) { break; } add(i, a); } } for (int x = 1; x <= n; x++) { cnt1 = 0; for (int i = Head[x]; i != -1; i = edge[i].next) { cnt1++;//记录这个人愿意和多少人交流 } if (cnt1 >= k) { ans++;//如果愿意和k个或以上的人交流,答案就+1 } } printf("%d", ans);//输出 return 0; } void add(int xx, int yy) { cnt++; edge[cnt].to = yy; edge[cnt].next = Head[xx]; Head[xx] = cnt; return; }
-
12019-11-12 17:50:15@
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int n,k,a[200],m=0,count=0;
cin>>n>>k;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>a[j];
count++;
if(a[j]==0)
{
count--;
break;
}
}
if(count>=k) m++;
count=0;
memset(a,'/0',sizeof(a));
}
cout<<m<<endl;
return 0;
}很怀疑这是不是太水了
-
12017-03-05 15:45:11@
...我记得贪心不简单的说,找到正确的贪心策略并不容易
-
12016-12-03 10:09:26@
没想清楚为什么是贪心
-
12016-10-28 19:49:35@
#include <stdio.h>
int main (void)
{
int n, k, temp, i, cnt, sum;
scanf("%d%d",&n,&k);
for (i=0, sum=0; i<n; i++) { for (cnt=0, temp=1; temp != 0; cnt++) { scanf("%d",&temp); } if (cnt >= k)
sum++;
}
printf("%d\n",sum);
return 0;
} -
12016-07-26 17:27:52@
var
a:array[0..201,0..201] of boolean;
x,j,ans,i,n,m,t:longint;
begin
readln(n,m);
for i:=1 to n do
begin
read(x);
while x<>0 do
begin
a[i,x]:=true; a[x,i]:=true;
read(x);
end;
end;
for i:=1 to n do
begin
t:=0;
for j:=1 to n do
if a[i,j]=true then inc(t);
if t>=m then inc(ans);
end;
writeln(ans);
end. -
12016-07-26 17:27:44@
var
a:array[0..201,0..201] of boolean;
x,j,ans,i,n,m,t:longint;
begin
readln(n,m);
for i:=1 to n do
begin
read(x);
while x<>0 do
begin
a[i,x]:=true; a[x,i]:=true;
read(x);
end;
end;
for i:=1 to n do
begin
t:=0;
for j:=1 to n do
if a[i,j]=true then inc(t);
if t>=m then inc(ans);
end;
writeln(ans);
end. -
12016-05-29 17:20:15@
无语的题目
include <stdio.h>
int main (void)
{
int n, k, temp, i, cnt, sum;
scanf("%d%d",&n,&k);
for (i=0, sum=0; i<n; i++) {
for (cnt=0, temp=1; temp != 0; cnt++) {
scanf("%d",&temp);
}
if (cnt >= k)
sum++;
}
printf("%d\n",sum);
return 0;
} -
02022-03-27 16:27:22@
#include <bits/stdc++.h>
using namespace std;int main()
{
int n, k;
cin >> n >> k;
int ans = 0;
for(int i=1; i<=n; i++)
{
int sum=0, t;
while(cin >> t && t != 0){
sum++;
}if(sum >= k)
ans++;}
cout << ans << endl;
return 0;
} -
02017-07-18 16:38:03@
读入+统计+比较=秒过!!!
var
n,k,s,x,c,i:longint;
begin
readln(n,k);
for i:=1 to n do begin
x:=0; read(c);
while c<>0 do begin
inc(x);read(c);
end;
if x>=k then inc(s);
readln;
end;
writeln(s);
end. -
02016-11-19 16:17:56@
var
n,k,ans,i,x,t:longint;
begin
readln(n,k);
ans:=0;
for i:=1 to n do
begin
t:=0;
read(x);
while x<>0 do
begin
inc(t);
read(x);
end;
if t>=k then inc(ans);
end;
writeln(ans);
end. -
02016-11-10 17:02:30@
这题有毒
python
n=0;k=0;sum=0;
n,k=raw_input().split(' ');
n=int(n);k=int(k);
for i in range(0,n):
t=raw_input().split(' ');
tt=len(t)-1;
if tt>=k :sum+=1;
print sum;
-
02016-05-12 15:14:54@
这种代码过了说明题目有问题。。。
```c++
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;const int maxn = 210;
int n;
int k;
int m;
vector<int> mem[maxn];int main ()
{
//freopen ("in.txt", "r", stdin);
cin >> n >> k;
int tem;
for (int i = 0; i < n; i++) {
while (cin >> tem) {
if (tem) mem[i].push_back(tem);
else break;
}
if (mem[i].size() >= k) m++;
}
cout << m;
return 0;
}
``` -
02016-03-27 16:29:52@
水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;int n,k,m,i,x,tot;
int main()
{
cin>>n>>k;
for (i=1;i<=n;i++)
{
cin>>x;tot=1;
while (x!=0)
{
tot++;
cin>>x;
}
if (tot>k) m++;
}
cout<<m<<endl;
} -
02016-03-01 20:58:58@
诡异的方法。。
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <algorithm>using namespace std;
int n,k,peo[1000];
struct{
int last;
int cnt;
}a[1000];
int main(){
memset(a,0,sizeof(a));
memset(peo,0,sizeof(peo));
scanf("%d%d",&n,&k);
int tmp;
for(int i = 1;i <= n;i ++){
scanf("%d",&tmp);
while(tmp != 0){
scanf("%d",&tmp);
a[i].last = a[i].cnt;
a[i].cnt ++;
peo[a[i].cnt] ++;
peo[a[i].last] --;
}
}
int ans = 0;
for(int i = k;i <= n;i ++){
ans += peo[i];
}
printf("%d",ans);
return 0;
} -
02015-11-01 16:56:13@
记录每个人认识多少个人就行了。
#include <iostream>
#include <fstream>
using namespace std;
typedef long long longint;
const int N=1000000;
longint r[N]={0};
longint n,k,m=0,rt;
int main()
{
//freopen("p1021.in","r",stdin);
//freopen("p1021.out","w",stdout);
cin>>n>>k;
for(int i=1;i<=n;i++)
{
for(;;)
{
cin>>rt;
if(rt==0)break;
else
{
r[rt]++;
r[i]++;
}
}
}
k=k<<1;
for(int i=1;i<=n;i++)
{
if(r[i]>=k)m++;
}
cout<<m;
return 0;
} -
02015-10-26 19:52:37@
我什么也不知道
var
a:array[0..201,0..201] of boolean;
x,j,ans,i,n,m,t:longint;
begin
readln(n,m);
for i:=1 to n do
begin
read(x);
while x<>0 do
begin
a[i,x]:=true; a[x,i]:=true;
read(x);
end;
end;
for i:=1 to n do
begin
t:=0;
for j:=1 to n do
if a[i,j]=true then inc(t);
if t>=m then inc(ans);
end;
writeln(ans);
end.