时间限制:0.5s空间限制:4M题意: 令X0=A, Xi=(a*Xi-1^2,b*Xi-1+c)%m; 求Xk,(0#include #include #include using namespace std;const int INF = 111111;vector ans;...
分类:
其他好文 时间:
2014-07-19 21:11:36
阅读次数:
259
在想更好的处理方法,现在却只能有这个糟烂的代码了……不好意思#include
#include
#include
using namespace std;
const int maxn=200;
char s[maxn];
double ans[maxn];
int get_num(int pos,int len)
{
int temp;
for(int i=pos;i<len...
分类:
其他好文 时间:
2014-07-18 18:07:51
阅读次数:
220
为了准备算法考试刷的,想明白一点就行,所有的传送门相当于一个点,当遇到一个传送门的时候,把所有的传送门都压入队列进行搜索
贴代码:
#include
#include
#include
#include
#include
using namespace std;
const int MAXN = 5000+50;
int r,c,f,si,sj,ei,ej,ans;...
分类:
其他好文 时间:
2014-07-18 14:08:32
阅读次数:
245
题解:直接使用STL中的hash去重即可#include #include using namespace std;int ans[50010];int main(){ int T,n,tmp; scanf("%d",&T); while(T--){ int cnt=...
分类:
其他好文 时间:
2014-07-17 10:02:58
阅读次数:
231
题意:
一串数字 问 有几种这样的组合(x,y,z)使得x>y>z或x
思路:
对于一个数字 比如 f 它计算出的ans值为
( beforef.lessthanf * afterf.biggerthanf )+( beforef.biggerthanf * afterf.lessthanf )
易知 beforef.biggerthanf = locationf - ...
分类:
其他好文 时间:
2014-07-16 17:25:35
阅读次数:
173
比较不错的一个题,关键是理解状态转移#include#include#include#include#define maxn 55using namespace std;int m,ans;int num[maxn],vis[maxn];bool cnt[1000009];int scale[10]...
分类:
其他好文 时间:
2014-07-16 15:06:35
阅读次数:
216
FRIENDS题意:找出最大的朋友圈#include #define N 30005int fa[N], ans[N];int find(int x){ return fa[x] == x ? x : fa[x] = find(fa[x]);}int main(int argc, char *...
分类:
其他好文 时间:
2014-07-15 08:48:35
阅读次数:
214
题目链接:点击打开链接
题意:
给定n行m列的矩阵 k次操作,一个常数p
ans = 0;
对于每次操作
可以任选一行或一列, 则ans += 这行(列)的数字和
然后这行(列)上的每个数字都-=p
问最大的ans
思路:
首先我们设最终选了 行 i 次,则列选了 k-i 次
那么假设我们先全部选行,然后选列,则每次选列时,要-= i*p
这样最后是 -= i...
分类:
其他好文 时间:
2014-07-14 17:38:20
阅读次数:
203
首先要知道选择行列操作时顺序是无关的
用两个数组row[i],col[j]分别表示仅选择i行能得到的最大值和仅选择j列能得到的最大值
这个用优先队列维护,没选择一行(列)后将这行(列)的和减去相应的np (mp)重新加入队列
枚举选择行的次数为i,那么选择列的次数为k - i次,ans = row[i] + col[k - i] - (k - i) * i * p;
既然顺序无关,...
分类:
其他好文 时间:
2014-07-14 16:44:35
阅读次数:
205
1 #include 2 #include 3 #include 4 #include 5 #define MAXN 25 6 using namespace std; 7 int h,w; 8 int ans; 9 int dir[4][2]={-1,0,1,0,0,-1,0,1};10 cha....
分类:
其他好文 时间:
2014-07-13 20:30:45
阅读次数:
215