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) 本题的 ...
随机推荐
- xml文件对应的DTD学习
DTD文件: 1.DTD文档主要由(元素,属性,实体,PCDATA,CDATA) 2.声明一个元素:<!ELEMENT 元素名称 (元素内容)> eg: <!ELEMENT pers ...
- onMeasure 出现java.lang.NullPointerException
直接在xml中使用自定义的布局.如自定义了一个view的onMeasure方法,如果此时引用Application就容易发生NullPointExecption异常.
- 用C#写的读写CSV文件
用C#写的读取CSV文件的源代码 CSV文件的格子中包含逗号,引号,换行等,都能轻松读取,而且可以把数据转化成DATATABLE格式 using System; using System.Text; ...
- 【摘抄】Application.StartupPath和System.Environment.CurrentDirectory的区别
System.Environment.CurrentDirectory的含义是获取或设置当前工作路径,而Application.StartupPath是获取程序启动路径,表面上看二者没什么区别,但实际 ...
- 10-排序5 PAT Judge
用了冒泡和插入排序 果然没有什么本质区别..都是运行超时 用库函数sort也超时 The ranklist of PAT is generated from the status list, whic ...
- UCOS2_STM32F1移植详细过程(一)
Ⅰ.概述 该文写针对初学µC/OS的朋友,基于以下平台来一步一步移植µC/OS嵌入式操作系统.UCOS移植相关平台: 系统平台:µC/OS-II (最新V2.92版) 硬件平台:STM32F1 ...
- vim之旅
本人是今年的毕业生, 大学很莫名的选择了一个电子商务专业. 由于专业没有实质性的东西可学,加上对电商不敢兴趣, 于是乎我有了大量的时间在宿舍里折腾电脑. 折腾了几年大三决定转业, 大四在还没找工作之前 ...
- python Django 学习笔记(一)—— Django安装
注:本人python版本2.7.5 ,win7系统 安装Django https://www.djangoproject.com/download/ 官方下载Django-1.5.5.tar.gz 1 ...
- python分片
刚刚学习,很新 >>> numbers = [1,2,3,4,5,6,7,8,9,10] >>> numbers[0:10:2] [1,3,5,7,9] >& ...
- ios中怎么样设置drawRect方法中绘图的位置
其中drawRect方法中的参数rect就是用来设置位置的,