| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:if(a/b<=2)和if(a<=2*b)有什么不同In Reply To:if(a/b<=2)和if(a<=2*b)有什么不同 Posted by:caolq at 2010-01-17 15:22:31 > AC的代码
> #include<stdio.h>
> int main()
> {
> int a,b,t,k;
> while(scanf("%d%d",&a,&b)&&(a!=0||b!=0))
> {
> if(a<b)
> {
> t=a;
> a=b;
> b=t;
> }
> if(a/b>=2||a%b==0)
> printf("Stan wins\n");
> else
> {
> k=0;
> while(a/b<2)
> {
> t=a;
> a=b;
> b=t-b;
> k++;
> }
> if(k%2)
> printf("Ollie wins\n");
> else
> printf("Stan wins\n");
> }
> }
> return 0;
> }
> WA的代码
> #include<stdio.h>
> int main()
> {
> int a,b,t,k;
> while(scanf("%d%d",&a,&b)&&(a!=0||b!=0))
> {
> if(a<b)
> {
> t=a;
> a=b;
> b=t;
> }
> if(a>=2*b||a%b==0)
> printf("Stan wins\n");
> else
> {
> k=0;
> while(a<2*b)
> {
> t=a;
> a=b;
> b=t-b;
> k++;
> }
> if(k%2)
> printf("Ollie wins\n");
> else
> printf("Stan wins\n");
> }
> }
> return 0;
> }
>
>
> 难道2*b超出数据范围
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator