http://codeforces.com/problemset/problem/305/A


这题就是意思没看懂,一开始以为只要个位数只要一个为0就能相加,没想到到CF里面提交第三组就过不了,才发现是要各个位上面都要有一个为0的时候才能相加。
题意很重要。。。。
AC代码:
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int k,i,j,n,t,x,y,z,x1,y1,z1,p;
  10. int d[110],a[110];
  11. while(scanf("%d",&k)!=EOF)
  12. {
  13. for(i = 0; i < k; i++)
  14. {
  15. scanf("%d",&d[i]);
  16. }
  17. sort(d,d+k);
  18. n = 1;
  19. a[0] = d[0];
  20. for(i = 1; i < k; i++)
  21. {
  22. t = d[i];
  23. x = t%10; //个位
  24. t = t/10;
  25. y = t%10; //十位
  26. t = t/10;
  27. z = t; //百位
  28. for(j = 0; j < n; j++)
  29. {
  30. p = a[j];
  31. x1 = p%10; //个位
  32. p = p/10;
  33. y1 = p%10; //十位
  34. p = p/10;
  35. z1 = p; //百位
  36. if((x==0||x1==0)&&(y==0||y1==0)&&(z==0||z1==0))
  37. {
  38. continue;
  39. }
  40. else
  41. {
  42. break;
  43. }
  44. }
  45. if(j == n)
  46. {
  47. a[n++] = d[i];
  48. }
  49. }
  50. printf("%d\n%d",n,a[0]);
  51. for(j = 1; j < n; j++)
  52. {
  53. printf(" %d",a[j]);
  54. }
  55. printf("\n");
  56. }
  57.  
  58. return 0;
  59. }

Strange Addition的更多相关文章

  1. CF 305A——Strange Addition——————【暴力加技巧】

    A. Strange Addition time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. codeforces A. Strange Addition 解题报告

    题目链接:http://codeforces.com/problemset/problem/305/A 题目意思:给出一个序列,需要从中选择一些数,这些数需要满足:任意的两个数中每一位至少有一个数满足 ...

  3. Solution -「CF 1380F」Strange Addition

    \(\mathcal{Description}\)   Link.   定义两个数在进行加法时,进位单独作为一位.例如: .   给定一个 \(n\) 为数和 \(m\) 次修改操作,每次修改会修改 ...

  4. codeforces305A

    Strange Addition CodeForces - 305A Unfortunately, Vasya can only sum pairs of integers (a, b), such ...

  5. Codeforces Round #184 (Div. 2)

    A. Strange Addition (目前的做法好像做烦了) 统计数的\(mask\),表示个.十.百位上是否是0,共8种数. 枚举8种数组成的所有情况\(2^8\),记录最大数量. B. Con ...

  6. [LeetCode] Range Addition 范围相加

    Assume you have an array of length n initialized with all 0's and are given k update operations. Eac ...

  7. iOS 之 SVN提交错误:"XXX" is scheduled for addition, but is missing

    今天使用SVN提交项目时,出现了这样的提示:"XXX" is scheduled for addition, but is missing.(无关紧要的东西用XXX代替). 看报错 ...

  8. timus 1175. Strange Sequence 解题报告

    1.题目描述: 1175. Strange Sequence Time limit: 1.0 secondMemory limit: 2 MB You have been asked to disco ...

  9. CF719C. Efim and Strange Grade[DP]

    C. Efim and Strange Grade time limit per test 1 second memory limit per test 256 megabytes input sta ...

随机推荐

  1. Codeforces Round #243 (Div. 1)A. Sereja and Swaps 暴力

    A. Sereja and Swaps time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. 详解Object.constructor

    对象的constructor属性引用了该对象的构造函数.对于 Object 对象,该指针指向原始的 Object() 函数.如下: var obj = {}; obj.constructor //ƒ ...

  3. .NET程序员提高效率的70多个开发工具

    工欲善其事,必先利其器,没有好的工具,怎么能高效的开发出高质量的代码呢?本文为各ASP.NET 开发者介绍一些高效实用的工具,涉及SQL 管理,VS插件,内存管理,诊断工具等,涉及开发过程的各个环节, ...

  4. DOM事件绑定方式

    普通事件可以直接绑定 比如document.onmouseover=fn; 或者document.addEventListener("mouseover",fn,flase); a ...

  5. ZOJ 2112 Dynamic Rankings (动态第k大,树状数组套主席树)

    Dynamic Rankings Time Limit: 10 Seconds      Memory Limit: 32768 KB The Company Dynamic Rankings has ...

  6. 介绍一下开源项目FastAnimationWithPOP

    介绍一下开源项目FastAnimationWithPOP JUL 23RD, 2014 这是一个非常easy的动画框架,基于Facebook的POP库. 使用它你就能够在故事版中以0行代码的代价来加入 ...

  7. IntelliJ IDEA使用教程三 SVN的集成与使用

    注意: 虽然IDEA已经集成了svn客户端,但还是习惯使用第三方svn客户端,比如: TortoiseSVN. 就是因为使用的是第三方客户端,所以和IDEA集成的时候就出现了一个特别大的坑,因为svn ...

  8. 吐槽Windows 8,就没见过这么烂的平板操作系统

    本文带有严重个人情感色彩,反感者慎入. CSDN 博文大赛得了个奖品,联想的平板电脑, MIIX2 8 .系统是 Windows 8 . 今天媳妇再次使用它,惹得我再次吐槽. 一句话.Windows ...

  9. JSPGen4 自学路线图

  10. 用最简单的例子理解模板方法模式(Template Method Pattern)

    假设要做一道红烧肉,做法有很多,在不同的做法中都有相同的部分,比如都要放油.放肉.放调料等.也有不同之处,比如有些做法放可乐,有些做法放甜蜜酱,等等. 先提炼出一个抽象类,该类不仅有制作红烧肉的各个步 ...