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) 本题的 ...
随机推荐
- DBGridEh 点击表头排序方法
方法1: (不用编程写代码) 程序中引用 单元 EhLibCDS设置DBGridEh的属性: ColumnDefValues.Title.TitleButton = True Op ...
- 2016/09/21 Java关键字final
1.final类 final类不能被继承,没有子类,final类中的方法默认是final的. final类不能被继承,因此final类的成员方法没有机会被覆盖,默认都是final的. 2.final方 ...
- 实战Django:官方实例Part3
前面两个部分我们介绍了投票应用的框架和后台管理部分.接下来舍得要介绍这个应用面向用户的界面. 这里我们要引入一个新的概念,"视图".在Django中,视图是一根连接模型和模板的纽带 ...
- 5.css字体
下面的用一个表格总结了文本样式中字体的一些设置方法: 属性名 说明 CSS 版本 font-size 设置字体的大小 1 font-variant 设置英文字体是否转换为小型大写 1 font-sty ...
- [转]判断程序是否运行在 Windows x64 系统下
以下功能代码判断是否运行在 Windows x64 下.本例使用 Windows API 函数 IsWow64Process,具体请参考MSDN文档:http://msdn.microsoft.com ...
- poj 2507Crossed ladders <计算几何>
链接:http://poj.org/problem?id=2507 题意:哪个直角三角形,一直角边重合, 斜边分别为 X, Y, 两斜边交点高为 C , 求重合的直角边长度~ 思路: 设两个三角形不重 ...
- [转]编译错误: /bin/sh: 1: pushd: not found的问题
[转]编译错误: /bin/sh: 1: pushd: not found的问题 http://blog.csdn.net/ojinxi/article/details/12186839 ubuntu ...
- 套接字I/O模型之WSAEventSelect
今天我又学习了一种新的套接字I/O模型------WSAEventSelect,他与WSAAsyncSelect一样也是一种异步事件通知模型,不同的是WSAAsyncSelect是与窗口句柄关联在一起 ...
- Sqrt(x)
Implement int sqrt(int x). Compute and return the square root of x. 参考:http://standalone.iteye.com/b ...
- 20145120 《Java程序设计》第10周学习总结
20145120 <Java程序设计>第10周学习总结 教材学习内容总结 转自:http://www.cnblogs.com/springcsc/archive/2009/12/03/16 ...