[ZJ]d180: 拿硬幣
題目:
http://zerojudge.tw/ShowProblem?problemid=d180
=================================================
#include<cstdio>
int main()
{
int a, sum0 =0, sum1 =0, b;
scanf("%d",&a);
while(a--){
scanf("%d",&b);
(a % 2 == 0? sum0 += b : sum1 += b) ;
}
printf("%s\n",(sum0 >sum1 ? "right" :"left" ));
return 0 ;
}
http://zerojudge.tw/ShowProblem?problemid=d180
=================================================
#include<cstdio>
int main()
{
int a, sum0 =0, sum1 =0, b;
scanf("%d",&a);
while(a--){
scanf("%d",&b);
(a % 2 == 0? sum0 += b : sum1 += b) ;
}
printf("%s\n",(sum0 >sum1 ? "right" :"left" ));
return 0 ;
}
留言
張貼留言