• topcoder srm 610 div2 250


    第一次做tc 的比赛,一点也不懂,虽然题目做出来了,

    但是,也没有在比赛的时候提交成功。。

    还有,感谢一宁对tc使用的讲解。。

    贴一下代码。。。。。

     1 #include <cstring>
     2 #include <vector>
     3 #include <cstdio>
     4 #include <iostream>
     5 using namespace std;
     6 
     7 class DivideByZero
     8 {
     9 public:
    10     int CountNumbers(vector<int>a)
    11     {
    12         int sum, f[300], flag2 = 0;
    13         int x;
    14         int i, j;
    15         sum = a.size();
    16         memset(f, 0, sizeof(f));
    17 
    18         for(i = 0; i < sum; i++)
    19             f[a[i]] = 1;
    20         while(1)
    21         {
    22             sum = a.size();
    23             flag2 = 0;
    24             for(i = 0; i < sum; i++)
    25                 for(j = 0; j < sum; j++)
    26                 {
    27                     if(a[j]!=0&&a[i]>a[j]&&i!=j)
    28                     {
    29                         x = a[i]/a[j];
    30                         if(f[x]==0)
    31                         {
    32                             a.push_back(x);
    33                             f[x] = 1;
    34                             flag2 = 1;
    35                         }
    36                     }
    37                 }
    38             if(flag2 == 0)
    39                 break;
    40         }
    41         return sum;
    42     }
    43 };
    44 
    45 /*int main()
    46 {
    47     vector<int>a;
    48     int n, ant, xx;
    49     cin>>n;
    50     for(int i = 0; i <n; i++)
    51     {
    52         cin>>xx;
    53         a.push_back(xx);
    54     }
    55     DivideByZero y1;
    56     ant = y1.CountNumbers(a);
    57     cout<<ant<<endl;
    58 }
    59 */
  • 相关阅读:
    世纪末的星期
    马虎的算式
    蜜蜂飞舞
    Torry 的困惑
    级数调和
    数列
    最大最小公倍数
    蚂蚁感冒
    12.integer to Roman
    13.Roman to Integer
  • 原文地址:https://www.cnblogs.com/bfshm/p/3569233.html
Copyright © 2020-2023  润新知