Topcoder srm 632 div2
脑洞太大,简单东西就是想复杂,活该一直DIV2;
A:水,基本判断A[I]<=A[I-1],ANS++;
B:不知道别人怎么做的,我的是100*N*N;没办法想的太多了,忘记是连续的数列
我们枚举公差,找到能有多少就可以了。
C:想到MAP,但是前面太脑掺,只有几分钟写。。
不过还真不一定写的出来。。
进来DP感觉良好。。
我们可以发现其实这些的乘积其实比较少。。
然后就像普通数组进行加法一样。
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i) typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long ll;
typedef pair<int,int> PII;
#define mod 1000000007 map<ll,ll> a[];
class GoodSubset
{
public:
int numberOfSubsets(int goodValue, vector <int> d)
{
int n=d.size();
ll ret=;
for (int i=;i<n;i++)
{
for (int j=;j<i;j++)
{
for (map<ll,ll>::iterator it=a[j].begin();it!=a[j].end();it++)
{
ll now=it->first;
int h=it->second;
if (goodValue%now==)
{
a[i][now*d[i]]+=h;
a[i][now*d[i]]%=mod;
}
}
}
a[i][d[i]]++;
a[i][d[i]]%=mod;
ret+=a[i][goodValue];
ret%=mod;
}
return ret;
}
}; int main() //模拟数据自测用
{
int n,m;
cin>>n>>m;
vector<int> p;
for (int i=;i<m;i++)
{
int x;
cin>>x;
p.push_back(x);
}
GoodSubset x;
cout<<x.numberOfSubsets(n,p);
return ;
} //代码还是很好看懂的
// Powered by FileEdit
// Powered by TZTester 1.01 [25-Feb-2003]
// Powered by CodeProcessor
Topcoder srm 632 div2的更多相关文章
- Topcoder Srm 673 Div2 1000 BearPermutations2
\(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对 ...
- Topcoder Srm 671 Div2 1000 BearDestroysDiv2
\(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...
- 求拓扑排序的数量,例题 topcoder srm 654 div2 500
周赛时遇到的一道比较有意思的题目: Problem Statement There are N rooms in Maki's new house. The rooms are number ...
- topcoder SRM 628 DIV2 BracketExpressions
先用dfs搜索所有的情况,然后判断每种情况是不是括号匹配 #include <vector> #include <string> #include <list> # ...
- topcoder SRM 628 DIV2 BishopMove
题目比较简单. 注意看测试用例2,给的提示 Please note that this is the largest possible return value: whenever there is ...
- Topcoder SRM 683 Div2 B
贪心的题,从左向右推过去即可 #include <vector> #include <list> #include <map> #include <set&g ...
- Topcoder SRM 683 Div2 - C
树形Dp的题,根据题意建树. DP[i][0] 表示以i为根节点的树的包含i的时候的所有状态点数的总和 Dp[i][1] 表示包含i结点的状态数目 对于一个子节点v Dp[i][0] = (Dp[v] ...
- Topcoder SRM 626 DIV2 SumOfPower
本题就是求所有连续子数列的和 开始拿到题目还以为求的时数列子集的和,认真看到题目才知道是连续子数列 循环遍历即可 int findSum(vector <int> array) { ; ; ...
- Topcoder SRM 626 DIV2 FixedDiceGameDiv2
典型的条件概率题目. 事件A在另外一个事件B已经发生条件下的发生概率.条件概率表示为P(A|B),读作“在B条件下A的概率”. 若只有两个事件A,B,那么, P(A|B)=P(AB)/P(B) 本题的 ...
随机推荐
- delphi中表示跳出的有break,continue, exit,abort, halt, runerror
1.break 强制退出循环(只能放在循环中),用于从For语句,while语句或repeat语句中强制退出. 2.continue 用于从For语句,while语句或repeat语句强行结束本次 ...
- python 遍历文件夹
import os import os.path rootdir = “d:\data” # 指明被遍历的文件夹 for parent,dirnames,filenames in os.walk(ro ...
- Python学习教程(learning Python)--1.2Python输入输出与处理
一般在做Python程序设计时,通常程序的结构由三部分组成: 输入语句,主要用于输入数据: 数据处理语句,一般对数据进行算术.逻辑等运算处理操作: 输出语句,将输入或者处理结果输出,用于与用户交互. ...
- ios view的frame和bounds之区别(位置和大小)
前言: 学习ios开发有一段时间了,项目也做了两个了,今天看视频,突然发现view的frame和bound两个属性,发现bound怎么也想不明白,好像饶你了死胡同里,经过一番尝试和思考,终于弄明白bo ...
- sublimeLinter-jshint 配置
这几天知道sublime3有可以对javascript进行语法检查的文件,折腾了一上午,搞定了. 记录一下步骤: 1.先安装nodejs. 2.npm install jshint -g 3.通过su ...
- oracle 临时表空间
环境: OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3. ...
- Postgres Basic Commands for Beginners
Just sharing what I have learned about postgres recently. Here is a part of basic commands you may n ...
- 基于HTML5的可预览多图片Ajax上传
一.关于图片上传什么什么的 在XHTML的时代,我们使用HTML file控件上传图片一次只能上传一张.要一次上传多图,做法是借助于flash.例如swfupload.js.可惜,使用复杂的点,比如f ...
- 解决vs2013不能添加控制器的步骤
点击:vs2013 更新,更新完以后,再重启下电脑就可以正常使用了
- 【分享】生成Revit扩展的addin文件小工具
在进行Revit二次开发的时候,加载命令/程序使用的是添加addin文件的方式,每次都需要手动的写,而且参数有好多,很不方便.于是乎我有了写一个小工具的想法.进过研究终于完成了.主要使用RevitAd ...