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) 本题的 ...
随机推荐
- .NET Framework4.0 下的多线程
一.简介 在4.0之前,多线程只能用Thread或者ThreadPool,而4.0下提供了功能强大的Task处理方式,这样免去了程序员自己维护线程池,而且可以申请取消线程等...所以本文主要描述Tas ...
- ref和out的区别
ref类型参数是按地址传递,能改变原来的数值.使用ref传参前,变量必须赋值. 带有ref类型参数的函数,不会清空变量,所以离开该函数的时候,所有ref引用的变量可以赋值也可以不赋值. out类型参数 ...
- Android--获取使用的总流量和每个App的上传、下载的流量
获得每个App的上传.下载的流量. 思路就是获取到我们手机上的所有app,再获得app里面使用的权限,如果app有网络权限,就显示出来. 代码很简单,代码里面也有比较详细的注释,下面直接上代码 布局文 ...
- hdu 4308 Saving Princess claire_
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4308 Saving Princess claire_ Description Princess cla ...
- HTTP上传文件探究
通常情况下,我们想在网页上上传一个文件的时候,会采用<input type="file">标签,但是你有没有想过,为什么通过这样一个标签,服务器端就能获取到文件数据呢? ...
- python 实现求和、计数、最大最小值、平均值、中位数、标准偏差、百分比。
import sys class Stats: def __init__(self, sequence): # sequence of numbers we will process # conver ...
- iOS之push present 动画
直接源码: - (void) transitionWithType:(NSString *) type WithSubtype:(NSString *) subtype ForView : (UIVi ...
- Python修饰器的函数式编程
Python的修饰器的英文名叫Decorator,当你看到这个英文名的时候,你可能会把其跟Design Pattern里的Decorator搞混了,其实这是完全不同的两个东西.虽然好像,他们要干的事都 ...
- [IOS] Storyboard全解析-第一部分
(Storyboard)是一个能够节省你很多设计手机App界面时间的新特性,下面,为了简明的说明Storyboard的效果,我贴上本教程所完成的Storyboard的截图: 现在,你就可以清楚的看到这 ...
- DHCP Server软件使用教程
DHCP Server软件使用教程 前提网络环境配置 电脑连接上wifi 网络和共享中心中更改适配器,共享无线网卡给以太网网卡 手动设置以太网网卡ipv4地址为192.168.1.1,子网掩码为255 ...