2011ACM成都赛区现场赛B题 (水题) (SPOJ9935)

水题,看了代码大家都明白的。

#include <stdio.h>
using namespace std;
int tt;
long long a,b,c,ans;
int main() {
    scanf("%d",&tt);
    for (int cas=1;cas<=tt;cas++) {
        scanf("%lld%lld%lld",&a,&b,&c);
        printf("Case #%d: %lld ",cas,a*b*c-1);
        ans=0;
        while (a>1) {
              if (a%2==0) a/=2;
              else a=a/2+1;
              ans++;
        }
        while (b>1) {
              if (b%2==0) b/=2;
              else b=b/2+1;
              ans++;
        }
        while (c>1) {
              if (c%2==0) c/=2;
              else c=c/2+1;
              ans++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}  


你可能感兴趣的:(c)