58 条题解
-
0zpyz LV 9 @ 2015-09-30 08:19:00
#include <stdio.h>
const int win[5][5] = {
0,0,1,1,0,
1,0,0,1,0,
0,1,0,0,1,
0,0,1,0,1,
1,1,0,0,0
};
int a[205], b[205];
int main()
{
fopen("rps.in","r");
fopen("rps.out","w");
int i,j,n, na, nb;
scanf("%d%d%d",&n,&na,&nb);
for (i = 0; i < na; ++i) scanf("%d",&a[i]);
for (i = 0; i < nb; ++i) scanf("%d",&b[i]);
i = 0, j = 0;
int ascore = 0, bscore = 0;
while (n) {
ascore += win[a[i]][b[j]];
bscore += win[b[j]][a[i]];
i = (i + 1) % na;
j = (j + 1) % nb;
n --;
}
printf("%d %d",ascore,bscore);
return 0;
} -
02015-09-27 16:27:56@
#include <cstdio>
#include <iostream>
using namespace std;
int f[6][6];
int n,na,nb,a[600],b[600],i,j,k,q,p;int main()
{
cin >>n>>na>>nb;
for (i=1;i<=na;i++)
cin >>a[i];
for (i=1;i<=nb;i++)
cin >>b[i];
a[0]=a[na];b[0]=b[nb];
f[0][1]=1;f[1][0]=2;f[0][2]=2;f[2][0]=1;f[0][3]=2;f[3][0]=1;
f[0][4]=1;f[4][0]=2;
f[1][2]=1;f[2][1]=2;f[1][3]=2;f[3][1]=1;f[1][4]=1;f[4][1]=2;
f[2][3]=1;f[3][2]=2;f[2][4]=2;f[4][2]=1;
f[3][4]=2;f[4][3]=1;
for (i=1;i<=n;i++)
{
if (f[a[i%na]][b[i%nb]]==2) q++;
else if (f[a[i%na]][b[i%nb]]==1) p++;
}
cout <<q<<" "<<p<<endl;
} -
02015-09-19 16:36:20@
#include<cstdio>
#define MAXN 200
const int win[5][5]={
{0,0,1,1,0},
{1,0,0,1,0},
{0,1,0,0,1},
{0,0,1,0,1},
{1,1,0,0,0}
};
int a[MAXN],b[MAXN];
int main(){
int n,na,nb;
scanf("%d%d%d",&n,&na,&nb);
for(int i=0;i!=na;++i)scanf("%d",&a[i]);
for(int i=0;i!=nb;++i)scanf("%d",&b[i]);
int ca=0,cb=0;
for(int i=0;i!=n;++i){
ca+=win[a[i%na]][b[i%nb]];
cb+=win[b[i%nb]][a[i%na]];
}
printf("%d %d",ca,cb);
} -
02015-09-01 22:19:22@
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;int n,na,nb,f[5][5],a[205],b[205],i,ai,bi,ta,tb;
int main()
{
cin>>n>>na>>nb;
for (i=1;i<=na;i++) cin>>a[i];
for (i=1;i<=nb;i++) cin>>b[i];//0剪刀;1石头;2布;3蜥蜴人;4斯波克
f[0][0]=0;f[0][1]=1;f[0][2]=2;f[0][3]=2;f[0][4]=1;
f[1][0]=2;f[1][1]=0;f[1][2]=1;f[1][3]=2;f[1][4]=1;
f[2][0]=1;f[2][1]=2;f[2][2]=0;f[2][3]=1;f[2][4]=2;
f[3][0]=1;f[3][1]=1;f[3][2]=2;f[3][3]=0;f[3][4]=2;
f[4][0]=2;f[4][1]=2;f[4][2]=1;f[4][3]=1;f[4][4]=0;
//0平;1输;2赢
ta=0;tb=0;
for (i=1;i<=n;i++)
{
ai++;bi++;
if (ai>na) ai=1;
if (bi>nb) bi=1;
if (f[a[ai]][b[bi]]==1) ta++;
if (f[a[ai]][b[bi]]==2) tb++;
}
cout<<tb<<' '<<ta<<endl;
}
太水不解释 -
02015-08-30 22:14:48@
简直酸爽
#include <cstdio>
#include <cstring>
#include <algorithm>
const int maxn=205;
int sequenceA[maxn],sequenceB[maxn];int main()
{
int N,Na,Nb;
scanf("%d%d%d",&N,&Na,&Nb);
for(int i=1;i<=Na;i++) scanf("%d",&sequenceA[i]);
for(int i=1;i<=Nb;i++) scanf("%d",&sequenceB[i]);int curA=1,curB=1;
int scoreA=0,scoreB=0;
for (int i=1;i<=N;i++) {
//printf("%d %d\n",sequenceA[curA],sequenceB[curB]);
switch(sequenceA[curA])
{
case 0:
switch(sequenceB[curB])
{
case 0:break;
case 1:scoreB++;break;
case 2:scoreA++;break;
case 3:scoreA++;break;
case 4:scoreB++;break;
}
break;
case 1:
switch(sequenceB[curB])
{
case 0:scoreA++;break;
case 1:break;
case 2:scoreB++;break;
case 3:scoreA++;break;
case 4:scoreB++;break;
}
break;
case 2:
switch(sequenceB[curB])
{
case 0:scoreB++;break;
case 1:scoreA++;break;
case 2:break;
case 3:scoreB++;break;
case 4:scoreA++;break;
}
break;
case 3:
switch(sequenceB[curB])
{
case 0:scoreB++;break;
case 1:scoreB++;break;
case 2:scoreA++;break;
case 3:break;
case 4:scoreA++;break;
}
break;
case 4:
switch(sequenceB[curB])
{
case 0:scoreA++;break;
case 1:scoreA++;break;
case 2:scoreB++;break;
case 3:scoreB++;break;
case 4:break;
}
break;
}
curA++;curB++;
if(curA>Na) curA-=Na;
if(curB>Nb) curB-=Nb;
}printf("%d %d",scoreA,scoreB);
return 0;
} -
02015-08-20 10:20:50@
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
int a[4000000],b[400000];
int main()
{
int n,na,nb,ansa,ansb,k,p;
scanf("%d%d%d",&n,&na,&nb);
for (int i=1;i<=na;i++)
scanf("%d",&a[i]);
for (int i=1;i<=nb;i++)
scanf("%d",&b[i]);
p=0;k=0;ansa=0;ansb=0;
for (int j=1;j<=n;j++)
{ k++;p++;
if (a[p]==0&&(b[k]==1||b[k]==4)) ansb++;
if (a[p]==0&&(b[k]==2||b[k]==3)) ansa++;
if (a[p]==1&&(b[k]==2||b[k]==4)) ansb++;
if (a[p]==1&&(b[k]==0||b[k]==3)) ansa++;
if (a[p]==2&&(b[k]==0||b[k]==3)) ansb++;
if (a[p]==2&&(b[k]==1||b[k]==4)) ansa++;
if (a[p]==3&&(b[k]==1||b[k]==0)) ansb++;
if (a[p]==3&&(b[k]==2||b[k]==4)) ansa++;
if (a[p]==4&&(b[k]==2||b[k]==3)) ansb++;
if (a[p]==4&&(b[k]==0||b[k]==1)) ansa++;
if (k>=nb) k=0;if (p>=na) p=0;
}
printf("%d %d\n",ansa,ansb);
return 0;
} -
02015-07-16 21:37:04@
#include<iostream>
using namespace std;
int circlea[201],circleb[201];
const int ifwin[5][5]={
{ 0,-1, 1, 1,-1},
{ 1, 0,-1, 1,-1},
{-1, 1, 0,-1, 1},
{-1,-1, 1, 0, 1},
{ 1, 1,-1,-1, 0}
};
int main()
{
int n,na,nb,ptsa=0,ptsb=0;
cin>>n>>na>>nb;
for(int i=0;i<na;i++)
cin>>circlea[i];
for(int i=0;i<nb;i++)
cin>>circleb[i];
for(int i=0;i<n;i++)
{
if(ifwin[circlea[i%na]][circleb[i%nb]]==1)ptsa++;
if(ifwin[circlea[i%na]][circleb[i%nb]]==-1)ptsb++;
}
cout<<ptsa<<" "<<ptsb;
return 0;
} -
02015-07-05 08:34:24@
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int N,NA,NB;
int A[1000],B[1000];
int a[10][10]={
{0,0,1,1,0},
{1,0,0,1,0},
{0,1,0,0,1},
{0,0,1,0,1},
{1,1,0,0,0},
};
int tota,totb;
int za=1;
int zb=1;
int main(){
cin>>N>>NA>>NB;
for(int i=1;i<=NA;i++) cin>>A[i];
for(int i=1;i<=NB;i++) cin>>B[i];
for(int i=1;i<=N;i++){
if(i==NA+1) za=1;
if(i==NB+1) zb=1;
int sa=A[za];
int sb=B[zb];
tota+=a[sa][sb];
totb+=a[sb][sa];
za++;
zb++;
}
cout<<tota<<" "<<totb;
return 0;
} -
02015-02-22 20:40:27@
看题目感觉不简单,数据范围瞬间暴击。。
直接暴力即可。Pascal Code
const
p:array[0..4,0..4] of longint= //p[i,j]代表i代表的手势与j代表的手势进行生活大爆炸版石头剪刀布所获得的分数
((0,0,1,1,0),
(1,0,0,1,0),
(0,1,0,0,1),
(0,0,1,0,1),
(1,1,0,0,0));
var
n,na,nb:longint;
ia,ib,ansa,ansb,j:longint;
a,b:array[1..200] of longint;
begin
readln(n,na,nb);
for ia:=1 to na do
read(a[ia]);
for ib:=1 to nb do
read(b[ib]);
ia:=0;
ib:=0;
ansa:=0;
ansb:=0;
j:=0;
repeat
ia:=ia mod na+1;
ib:=ib mod nb+1;
ansa:=ansa+p[a[ia],b[ib]];
ansb:=ansb+p[b[ib],a[ia]];
inc(j);
until j=n;
writeln(ansa,' ',ansb);
end. -
02015-02-10 16:28:12@
http://shadowchaser.lofter.com/post/1d04e306_5bf0c8c
N=200,暴力。
#include <cstdio>
#include <cstring>
#include <cstdlib>using namespace std;
const int d[5][5]={ 0,-1,1,1,-1,
1,0,-1,1,-1,
-1,1,0,-1,1,
-1,-1,1,0,1,
1,1,-1,-1,0 };
const int N=201;int n;
int da[N],db[N],nowa,nowb,na,nb;
int wa,wb;int main(void)
{
scanf("%d%d%d",&n,&na,&nb);
for (int i=1;i<=na;i++) scanf("%d",&da[i]);
for (int i=1;i<=nb;i++) scanf("%d",&db[i]);
for (int i=1;i<=n;i++)
{
nowa=nowa%na+1;
nowb=nowb%nb+1;
if (d[da[nowa]][db[nowb]]==1) wa++; else if (d[da[nowa]][db[nowb]]==-1) wb++;
}
printf("%d %d\n",wa,wb);
return 0;
} -
02015-02-07 23:10:12@
记录信息
评测状态 Accepted
题目 P1905 生活大爆炸版 石头剪刀布
递交时间 2015-02-07 23:09:47
代码语言 C++
评测机 VijosEx
消耗时间 30 ms
消耗内存 480 KiB
评测时间 2015-02-07 23:09:49评测结果
编译成功
测试数据 #0: Accepted, time = 0 ms, mem = 476 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 480 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 480 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 480 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 476 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 476 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 480 KiB, score = 10
测试数据 #7: Accepted, time = 15 ms, mem = 480 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 480 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 476 KiB, score = 10
Accepted, time = 30 ms, mem = 480 KiB, score = 100
代码
#include <iostream>
#include <stdio.h>using namespace std;
int n;
int na , nb;
int a[200 + 10];
int b[200 + 10];
int win[ 6 ][ 6 ];
int i , j;
int cnt_a , cnt_b;void init()
{
cnt_a = cnt_b = 0;
win[0][0] = win[1][1] = win[2][2] = win[3][3] = win[4][4] = 0;
win[0][1] = 0;
win[0][2] = 1;
win[0][3] = 1;
win[0][4] = 0;
win[1][0] = 1;
win[1][2] = 0;
win[1][3] = 1;
win[1][4] = 0;
win[2][0] = 0;
win[2][1] = 1;
win[2][3] = 0;
win[2][4] = 1;
win[3][0] = 0;
win[3][1] = 0;
win[3][2] = 1;
win[3][4] = 1;
win[4][0] = 1;
win[4][1] = 1;
win[4][2] = 0;
win[4][3] = 0;
return;
}int main()
{
init();
scanf( "%d %d %d" , &n , &na , &nb );
for( i = 0 ; i < na ; i++ )
scanf( "%d" , &a[ i ] );
for( j = 0 ; j < nb ; j++ )
scanf( "%d" , &b[ j ] );
for( i = 0 ; i < n ; i++ )
{
cnt_a += win[ a[ i % na ] ][ b[ i % nb ] ];
cnt_b += win[ b[ i % nb ] ][ a[ i % na ] ];
}
cout << cnt_a << " " << cnt_b << endl;
return 0;
} -
02015-01-24 11:53:27@
var a:array[0..4,0..4]of longint;
na,nb,i,j,sa,sb,n,b,c:longint;
xa,xb:array[1..200]of longint;
ya,yb:array[1..40000]of longint;
begin
b:=1;c:=1;
a[0,0]:=0;a[0,1]:=0;a[0,2]:=1;a[0,3]:=1;a[0,4]:=0;
a[1,0]:=1;a[1,1]:=0;a[1,2]:=0;a[1,3]:=1;a[1,4]:=0;
a[2,0]:=0;a[2,1]:=1;a[2,2]:=0;a[2,3]:=0;a[2,4]:=1;
a[3,0]:=0;a[3,1]:=0;a[3,2]:=1;a[3,3]:=0;a[3,4]:=1;
a[4,0]:=1;a[4,1]:=1;a[4,2]:=0;a[4,3]:=0;a[4,4]:=0;//胜负
read(n,na,nb);
for i:=1 to na do read(xa[i]);
for i:=1 to nb do read(xb[i]);
for i:=1 to n do
begin
ya[i]:=xa[b];
inc(b);
if b>na then b:=1;
yb[i]:=xb[c];
inc(c);
if c>nb then c:=1;
end;//判断
for i:=1 to n do
begin
sa:=sa+a[ya[i],yb[i]];
sb:=sb+a[yb[i],ya[i]];
end;
writeln(sa,' ',sb);
end. -
02015-01-24 11:53:12@
var a:string;
i,b:longint;
flag2:boolean;
begin
flag2:=true;
readln(a);
b:=length(a);
for i:=length(a) downto 1 do
if (a[i]='0')and(flag2=true) then dec(b)
else if(a[i]<>'0')then flag2:=false;
if a[1]='-' then
begin
write('-');
for i:=b downto 2 do write(a[i])
end;
if a[1]<>'-'then
for i:=b downto 1 do write(a[i]);
end. -
02015-01-09 19:05:12@
###block code
program ex;
var data:array[0..4,0..4] of longint;
na,nb,n,i,k,num,la,lb,ansa,ansb:longint;
a,b:array[1..200] of longint;
begin
read(n); read(na); read(nb);
la:=0;
lb:=0;
ansa:=0;
ansb:=0;
for i:=1 to na do
begin
read(num);
a[i]:=num;
end;for i:=1 to nb do
begin
read(num);
b[i]:=num;
end;for i:=0 to 4 do
data[i,i]:=0;data[1,0]:=1; data[2,0]:=2; data[2,1]:=1; data[3,0]:=2;
data[3,1]:=2; data[3,2]:=1; data[4,0]:=1; data[4,1]:=1;
data[4,2]:=2; data[4,3]:=2;for i:=1 to n do
begin
inc(la); inc(lb);
if la=na+1 then
la:=1;
if lb=nb+1 then
lb:=1;
if a[la]=b[lb] then
continue;
if a[la]>b[lb] then
begin
if data[a[la],b[lb]]=1 then
inc(ansa);
if data[a[la],b[lb]]=2 then
inc(ansb);
end;if a[la]<b[lb] then
begin
if data[b[lb],a[la]]=1 then
inc(ansb);
if data[b[lb],a[la]]=2 then
inc(ansa);
end;
end;
write(ansa,' ',ansb);
end. -
02014-12-13 20:11:55@
打表ac无压力
#include<iostream>
using namespace std;
bool pk(int a,int b);
int main()
{
int a[201],b[201],n,na,nb,s,i,j,ansa=0,ansb=0;
cin>>n>>na>>nb;
for (i=0;i<na;i++) cin>>a[i];
for (i=0;i<nb;i++) cin>>b[i];
s=i=j=0;
while (s<n)
{
if (i==na) i=0;
if (j==nb) j=0;
if (pk(a[i],b[j])==1) ansa++;
if (pk(b[j],a[i])==1) ansb++;
s++; i++; j++;
}
cout<<ansa<<" "<<ansb;
return 0;
}
bool pk(int a,int b)
{
if (a==0&&b==2) return 1;
else if (a==0&&b==3) return 1;
else if (a==1&&b==0) return 1;
else if (a==1&&b==3) return 1;
else if (a==2&&b==1) return 1;
else if (a==2&&b==4) return 1;
else if (a==3&&b==2) return 1;
else if (a==3&&b==4) return 1;
else if (a==4&&b==0) return 1;
else if (a==4&&b==1) return 1;
else return 0;
} -
02014-12-01 13:06:24@
凭印象写的。。。
program ciac;
var n,na,nb,s,aa,bb,i,tota,totb:integer;
a,b:array[1..200]of integer;
flag,ping,aying,bying:boolean;
begin
readln(n,na,nb);
for i:=1 to na do
read(a[i]);
readln;
for i:=1 to nb do
read(b[i]);
readln;
aa:=1;
bb:=1;
tota:=0;
totb:=0;
for i:=1 to n do
begin
flag:=false;
ping:=false;
aying:=false;
bying:=false;
s:=a[aa]*a[aa]+b[bb]*b[bb];
if a[aa]>b[bb] then flag:=true;
case s of
0,2,8,18,32:ping:=true;
4,9,10,20,25:aying:=true;
1,16,5,17,13:bying:=true;
end;
if not ping then if flag then begin
aying:=not aying; bying:=not bying;
end;
if aying then inc(tota);
if bying then inc(totb);
inc(aa);
inc(bb);
if aa>na then aa:=1;
if bb>nb then bb:=1;
end;
writeln(tota,' ',totb);
end. -
02014-11-23 20:58:37@
简单的模拟题。
if 判断即可 -
-12016-08-23 12:50:28@
我就想问这么这么这么这么这么这么这么这么这么水水水水水水的题目,你们的代码怎么做到这样又臭又长的?
c++
#include <iostream>
using namespace std;
short n,na,nb,a[205],b[205],ca,cb;
bool list[5][5]={{0,0,1,1,0},{1,0,0,1,0},{0,1,0,0,1},{0,0,1,0,1},{1,1,0,0,0}};
int main()
{
cin>>n>>na>>nb;
for(int i=0;i<na;i++)cin>>a[i];
for(int i=0;i<nb;i++)cin>>b[i];
for(int i=0;i<n;i++)ca+=list[a[i%na]][b[i%nb]],cb+=list[b[i%nb]][a[i%na]];
cout<<ca<<" "<<cb;
return 0;
}