HDU3953 I'll play a trick on you
来源:互联网 发布:上海万达网络科技集团 编辑:程序博客网 时间:2024/05/21 10:49
分析上图中的数字,很容易误以为样例就是求A,B之差的,但是发现图中的最后一个数字是“7”,不符合这一规律的,再对图进行观察,可以发现,如下规律:
99 72 “=>” 9+9=18 ,7+2=9 18+9=27;
45 27 “=>” 4+5=9, 2+7=9 9+9=18;
39 18 “=>” 3+9=12, 1+8=9, 12+9=21;
36 21 “=>” 3+6=9, 2+1 =3, 9+3=12;
28 12 “=>” 2+8=10, 1+2=3 , 10+3=13;
99 72 “=>” 9+9=18 ,7+2=9 18+9=27;
45 27 “=>” 4+5=9, 2+7=9 9+9=18;
39 18 “=>” 3+9=12, 1+8=9, 12+9=21;
36 21 “=>” 3+6=9, 2+1 =3, 9+3=12;
28 12 “=>” 2+8=10, 1+2=3 , 10+3=13;
21 13 “=>”2+1=3, 1+3=4 ,3+4=7;
#include<stdio.h>
#include<string.h>
int main()
{
int n,i,sum,k,t;
char a[101],b[101];
scanf("%d\n",&n);
while(n--)
{
sum=0;
scanf("%s%s",a,b);
k=strlen(a);
t=strlen(b);
for(i=0;i<k;i++)
sum+=a[i]-'0';
for(i=0;i<t;i++)
sum+=b[i]-'0';
printf("%d\n",sum);
}
return 0;
}
字符串处理只要每个数字都加起来,和就为所求结果:99 72
#include<stdio.h>
int main()
{
int n, c, i;
for(scanf("%d\n", &n); n--; printf("%d\n", i))
for(i = 0; (c = getchar()) != '\n'; i += (c - 32 ? c - '0' : 0));
return 0;
}
0 0
- HDU3953 I'll play a trick on you
- I'll play a trick on you
- I'll play a trick on you
- hdu 3953 I'll play a trick on you
- hdu 3953 I'll play a trick on you
- HDu--3935(I'll play a trick on you)
- hdu 3953 I'll play a trick on you
- hdu 3953 I'll play a trick on you
- HDU:3953 I'll play a trick on you
- NYOJ 400题 I'll play a trick on you
- nyoj-400-I'll play a trick on you
- NYOJ 400 I'll play a trick on you
- NYOJ 题目400 I'll play a trick on you
- ACM-I'll play a trick on you
- ACM_ I'll play a trick on you
- 2011阿里巴巴程序设计公开赛 1003 I'll play a trick on you
- 2011阿里巴巴程序设计公开赛 / 1003 I'll play a trick on you
- I'll play a trick on you(2011 Alibaba Programming Contest)
- 求助!itk读取保存图像问题!
- jquery 选择器(name,属性,元素)大全
- HTTP幂等性
- C# 队列(Queue)
- Ubuntu下搭建eclipse开发环境
- HDU3953 I'll play a trick on you
- 第一个Cocos2d-x Lua游戏
- hdu 1599find the mincost route(Floyd算法,最小环无向图)
- JavaScript获取当前系统时间
- LR安装遇到 Cannot save the license information because access to the registry is denied
- Mapreduce中的 自定义类型、分组与二次排序
- P122第30题
- 一步一步学习 Linux 驱动之设备控制接口函数(ioctl 函数)
- 安装LoadRunner时提示缺少vc2005_sp1_with_atl_fix_redist解决方案