Strange Addition
来源:互联网 发布:物理机安装centos系统 编辑:程序博客网 时间:2024/05/29 15:05
http://codeforces.com/problemset/problem/305/A
这题就是意思没看懂,一开始以为只要个位数只要一个为0就能相加,没想到到CF里面提交第三组就过不了,才发现是要各个位上面都要有一个为0的时候才能相加。
题意很重要。。。。
AC代码:
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;int main(){ int k,i,j,n,t,x,y,z,x1,y1,z1,p; int d[110],a[110]; while(scanf("%d",&k)!=EOF) { for(i = 0; i < k; i++) { scanf("%d",&d[i]); } sort(d,d+k); n = 1; a[0] = d[0]; for(i = 1; i < k; i++) { t = d[i]; x = t%10; //个位 t = t/10; y = t%10; //十位 t = t/10; z = t; //百位 for(j = 0; j < n; j++) { p = a[j]; x1 = p%10; //个位 p = p/10; y1 = p%10; //十位 p = p/10; z1 = p; //百位 if((x==0||x1==0)&&(y==0||y1==0)&&(z==0||z1==0)) { continue; } else { break; } } if(j == n) { a[n++] = d[i]; } } printf("%d\n%d",n,a[0]); for(j = 1; j < n; j++) { printf(" %d",a[j]); } printf("\n"); } return 0;}
- Strange Addition
- codeforces-305A Strange Addition
- CF--518A--Strange Addition
- codeforce-305A--Strange Addition (贪心)
- codeforces 305A Strange Addition (模拟)
- CF 305A(Strange Addition-贪心+分类讨论)
- codeforces Round #184 Div.2 - A. Strange Addition
- CodeForces 305A Strange Addition(想法题)
- codeforces-305A Strange Addition(思维+模拟)
- CodeForces 305A Strange Addition(思维题)
- Martian Addition
- ZOJ_1205_Martian Addition
- Simple Addition
- binary addition
- zoj1205Martian Addition
- Learning Addition
- NSArray+Addition
- NSDate+Addition
- corona new button(按钮的使用)
- 1423 Greatest Common Increasing Subsequence (LCIS)
- opencv帧差法、中值滤波与二值化
- 【Wn8中如何关闭或开启自动播放功能】
- sql 选出所有人的最小成绩
- Strange Addition
- 同时设置两个 Bootstrap nav menus
- hdu 3940
- SOCKET API和TCP STATE的对应关系__三次握手(listen,accept,connect)__四次挥手close及TCP延迟确认(调用一次setsockopt函数,设置TCP_QUI
- Linux设备驱动程序——Linux设备驱动程序——内存和I/O基础知识学习:(2)内核中相关基础知识学习
- SSI(Struts2, Spring, iBatis)框架整合图示
- Android之多媒体--使用VideoView播放视频
- ARM分类
- Linux线程-互斥锁pthread_mutex_t