您的位置:首页 > 其它

FZU 2089 数字游戏

2013-11-05 19:30 218 查看
FZU 2089 数字游戏                      题目连接:http://acm.fzu.edu.cn/problem.php?pid=2089



题目分析:大数,long long可解。

code:

#include<stdio.h>
int main()
{
int i,t,count;
long long a,b,sum;
scanf("%d",&t);
while(t--)
{
scanf("%I64d%I64d",&a,&b);
sum=a+b;
count=0;
while(sum)
{
count+=sum%10==5?1:0;
sum/=10;
}
printf("%d\n",count);
}
return 0;
}

PS:linux下大数很奇葩,自己测试时定义long long,输入用的%lld,能运行;用%I64d,报如下错误:

/shiziyouxi.cpp|9|警告: 格式 ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat]|
/shiziyouxi.cpp|9|警告: 格式 ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘long long int*’ [-Wformat]|
||=== Build finished: 2 errors, 0 warnings ===|

提交则相反,用%lld交,wrong;用%I64d,A了……这是怎么一回事??
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: