zoukankan      html  css  js  c++  java
  • Topcoder srm 632 div2

    脑洞太大,简单东西就是想复杂,活该一直DIV2;

    A:水,基本判断A[I]<=A[I-1],ANS++;

    B:不知道别人怎么做的,我的是100*N*N;没办法想的太多了,忘记是连续的数列

    我们枚举公差,找到能有多少就可以了。

    C:想到MAP,但是前面太脑掺,只有几分钟写。。

    不过还真不一定写的出来。。

    进来DP感觉良好。。

    我们可以发现其实这些的乘积其实比较少。。

    然后就像普通数组进行加法一样。

     1 #include <cstdlib>
     2 #include <cctype>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <cmath>
     6 #include <algorithm>
     7 #include <vector>
     8 #include <string>
     9 #include <iostream>
    10 #include <sstream>
    11 #include <map>
    12 #include <set>
    13 #include <queue>
    14 #include <stack>
    15 #include <fstream>
    16 #include <numeric>
    17 #include <iomanip>
    18 #include <bitset>
    19 #include <list>
    20 #include <stdexcept>
    21 #include <functional>
    22 #include <utility>
    23 #include <ctime>
    24 using namespace std;
    25 
    26 #define PB push_back
    27 #define MP make_pair
    28 
    29 #define REP(i,n) for(i=0;i<(n);++i)
    30 #define FOR(i,l,h) for(i=(l);i<=(h);++i)
    31 #define FORD(i,h,l) for(i=(h);i>=(l);--i)
    32 
    33 typedef vector<int> VI;
    34 typedef vector<string> VS;
    35 typedef vector<double> VD;
    36 typedef long long ll;
    37 typedef pair<int,int> PII;
    38 #define mod  1000000007
    39 
    40 
    41 map<ll,ll> a[111];
    42 class GoodSubset
    43 {
    44         public:
    45         int numberOfSubsets(int goodValue, vector <int> d)
    46         {
    47                int  n=d.size();
    48                ll ret=0;
    49                for (int i=0;i<n;i++)
    50                {
    51                    for (int j=0;j<i;j++)
    52                    {
    53                        for (map<ll,ll>::iterator it=a[j].begin();it!=a[j].end();it++)
    54                        {
    55                            ll now=it->first;
    56                            int h=it->second;
    57                            if (goodValue%now==0)
    58                            {
    59                                a[i][now*d[i]]+=h;
    60                                a[i][now*d[i]]%=mod;
    61                            }
    62                        }
    63                    }
    64                    a[i][d[i]]++;
    65                    a[i][d[i]]%=mod;
    66                    ret+=a[i][goodValue];
    67                    ret%=mod;
    68                }
    69                return ret;
    70         }
    71 };
    72 
    73 int main() //模拟数据自测用
    74 {
    75     int n,m;
    76     cin>>n>>m;
    77     vector<int> p;
    78     for (int i=0;i<m;i++)
    79     {
    80         int x;
    81         cin>>x;
    82         p.push_back(x);
    83     }
    84     GoodSubset x;
    85     cout<<x.numberOfSubsets(n,p);
    86     return 0;
    87 }
    88 
    89 
    90 //代码还是很好看懂的
    91 // Powered by FileEdit
    92 // Powered by TZTester 1.01 [25-Feb-2003]
    93 // Powered by CodeProcessor
  • 相关阅读:
    5.19 省选模拟赛 T1 小B的棋盘 双指针 性质
    5.15 省选模拟赛 容斥 生成函数 dp
    5.15 省选模拟赛 T1 点分治 FFT
    5.15 牛客挑战赛40 B 小V的序列 关于随机均摊分析 二进制
    luogu P4929 【模板】舞蹈链 DLX
    CF 878E Numbers on the blackboard 并查集 离线 贪心
    5.10 省选模拟赛 拍卖 博弈 dp
    5.12 省选模拟赛 T2 贪心 dp 搜索 差分
    5.10 省选模拟赛 tree 树形dp 逆元
    luogu P6088 [JSOI2015]字符串树 可持久化trie 线段树合并 树链剖分 trie树
  • 原文地址:https://www.cnblogs.com/forgot93/p/3958951.html
Copyright © 2011-2022 走看看