测试结果错误.错误结果为:147483648
正确结果应为:2147483648
测试结果错误.错误结果为:97152
正确结果应为:2097152
测试结果错误.错误结果为:62143
正确结果应为:262144
var
a , b : dword;
begin
readln ( a ); b := 0;
while a <> a and -a do begin
inc ( b , a and -a );
dec ( a , a and -a );
end;
if b<<1 < a then write ( b )
else writeln ( a - b );
end.
var
a , b : dword;
begin
readln ( a ); b := 1;
while b < a do b := b << 1;
if b-a > a-b>>1 then writeln ( a-b>>1 )
else writeln ( b-a );
end.
貌似数据是错的?
测试结果错误.错误结果为:147483648
正确结果应为:2147483648
测试结果错误.错误结果为:97152
正确结果应为:2097152
测试结果错误.错误结果为:62143
正确结果应为:262144
var
a , b : dword;
begin
readln ( a ); b := 0;
while a <> a and -a do begin
inc ( b , a and -a );
dec ( a , a and -a );
end;
if b<<1 < a then write ( b )
else writeln ( a - b );
end.
var
a , b : dword;
begin
readln ( a ); b := 1;
while b < a do b := b << 1;
if b-a > a-b>>1 then writeln ( a-b>>1 )
else writeln ( b-a );
end.
[/quote]
嗯...
貌似数据是错的?
测试结果错误.错误结果为:147483648
正确结果应为:2147483648
测试结果错误.错误结果为:97152
正确结果应为:2097152
测试结果错误.错误结果为:62143
正确结果应为:262144
var
a , b : dword;
begin
readln ( a ); b := 0;
while a <> a and -a do begin
inc ( b , a and -a );
dec ( a , a and -a );
end;
if b<<1 < a then write ( b )
else writeln ( a - b );
end.
var
a , b : dword;
begin
readln ( a ); b := 1;
while b < a do b := b << 1;
if b-a > a-b>>1 then writeln ( a-b>>1 )
else writeln ( b-a );
end.
[/quote]
错一摸一样......
状态: Accepted
测评机: Xeost[5]
得分: 100分
提交日期: 2011-3-20 20:46:00
有效耗时: 640毫秒
测试结果1: 通过本测试点|有效耗时125ms
测试结果2: 通过本测试点|有效耗时47ms
测试结果3: 通过本测试点|有效耗时47ms
测试结果4: 通过本测试点|有效耗时46ms
测试结果5: 通过本测试点|有效耗时47ms
测试结果6: 通过本测试点|有效耗时47ms
测试结果7: 通过本测试点|有效耗时47ms
测试结果8: 通过本测试点|有效耗时47ms
测试结果9: 通过本测试点|有效耗时47ms
测试结果10: 通过本测试点|有效耗时47ms
测试结果11: 通过本测试点|有效耗时47ms
测试结果12: 通过本测试点|有效耗时46ms
也许我们什么有情况没有考虑到?
状态: Unaccepted
测评机: Xeond[6]
得分: 75分
提交日期: 2011-3-23 16:31:00
有效耗时: 421毫秒
测试结果1: 通过本测试点|有效耗时47ms
测试结果2: 通过本测试点|有效耗时46ms
测试结果3: 测试结果错误.错误结果为:147483648
正确结果应为:2147483648
测试结果4: 通过本测试点|有效耗时47ms
测试结果5: 通过本测试点|有效耗时47ms
测试结果6: 测试结果错误.错误结果为:97152
正确结果应为:2097152
测试结果7: 测试结果错误.错误结果为:62143
正确结果应为:262144
测试结果8: 通过本测试点|有效耗时47ms
测试结果9: 通过本测试点|有效耗时47ms
测试结果10: 通过本测试点|有效耗时46ms
测试结果11: 通过本测试点|有效耗时47ms
测试结果12: 通过本测试点|有效耗时47ms
提交代码: view sourceprint?01.
#include<stdio.h>
int main()
{
int n,s=1,k;
scanf("%d",&n);
int k0=n;
while(1)
{
s=s*2;
k=abs(n-s);
if(k>k0)
break;
else k0=k;
}
printf("%d",k0);
return 0;
}