码迷,mamicode.com
首页 >  
搜索关键字:ans    ( 3741个结果
poj 3399 Product(模拟)
# include # include # include using namespace std; int cmp(int x,int y) { return x>y; } int main() { int a[110],a1[110],a2[110],ans[110]; int n,k,k1,k2,i,k3; while(~scanf("%d%d",&n,&k)) { k1...
分类:其他好文   时间:2014-08-04 21:46:48    阅读次数:237
ACdream 1148 GCD SUM (久违的莫比乌斯)
题目链接 题意:给出N,M 执行如下程序: long long  ans = 0,ansx = 0,ansy = 0; for(int i = 1; i    for(int j = 1; j        if(gcd(i,j) == 1) ans ++,ansx += i,ansy += j; cout 思路: 首先要会莫比乌斯,然后对于ans,自然是非常好求...
分类:其他好文   时间:2014-08-04 14:20:37    阅读次数:220
HDU 4910 HDOJ Problem about GCD BestCoder #3 第四题
首先 m = 1 时 ans = 0对于 m > 1 的 情况 由于 1 到 m-1 中所有和m互质的数字,在 对m的乘法取模 运算上形成了群 ai = ( 1 2的情况,只需求a^2 = 1 (mod m)的解的个数是不是4的倍数a^2 = 1 (mod m) 等价变换(a + 1)(a -...
分类:其他好文   时间:2014-08-04 14:15:17    阅读次数:284
hdu 4908 BestCoder Sequence 找M为中位数的串的数目, 需要预处理
题目意思是 再给出的全排列(1~n每个数字只出现一次)中,找到一个奇数个的子串,要求子串的中位数(大小排序后正中间的数), 为M; 求这种子串有多少. 首先要把M这个数左边的串预处理下, 如果 遇到大于M的数ji++,然后记录在data[当前位置的奇偶][当前记录的ji] ,如果当前位置的数小于M的数,ji--; 因为ji记录在数组里,所以ji 要价格50000 以保证不会出现负数的情况. 然后再处理右边的串,ji 重新计数, ans+data[位置奇偶, 如果两个位置奇偶相同,代表这条串有奇数个元...
分类:其他好文   时间:2014-08-04 11:05:17    阅读次数:238
LeetCode--Combination Sum II
思路:类似于上一题,但是加了一个index数组记录结果里面已经存放的元素索引,用来判断当前的元素是否和上一个相同并且上一个是否使用过。主要为了解决重复解的问题。 1 class Solution { 2 public: 3 vector >ans; 4 vector > combin...
分类:其他好文   时间:2014-08-03 23:01:56    阅读次数:213
1753 Flip Game
#include#include#include#includeusing namespace std;int pieces[10][10];int ans[16];int res[4][4];int Min=1000000;const int INF=1=0) res...
分类:其他好文   时间:2014-08-03 15:14:55    阅读次数:228
LA 3905 Meteor
给出一些点的初始位置(x, y)及速度(a, b)和一个矩形框,求能同时出现在矩形框内部的点数的最大值。把每个点进出矩形的时刻分别看做一个事件,则每个点可能对应两个事件,进入事件和离开事件。按这些事件的发生时间进行排序,然后逐个扫描,遇到进入事件cnt++,遇到离开事件--cnt,用ans记录cnt...
分类:其他好文   时间:2014-08-02 23:10:24    阅读次数:307
UVA 11019 - Matrix Matcher(AC自动机)
UVA 11019 - Matrix Matcher 题目链接 题意:给定两个矩阵字符串,要求第二个矩阵在第一个矩阵的出现次数 思路:第二个矩阵按行拆分成自动机,然后用第一个矩阵一行一行去匹配,利用一个rc[N][M]的数组记录下每个左上角对应位置的成功匹配次数,然后找完后,对于每个位置,如果成功匹配次数为x,那么就是成功匹配上了,ans++ 代码: #include...
分类:其他好文   时间:2014-08-02 15:31:33    阅读次数:198
HDU2647 Reward 【拓扑排序】
#include #include #define maxn 10002 int ans, queue[maxn]; struct Node{ int to, next, val; } map[maxn << 1]; struct node{ int first, money, indegree; } head[maxn]; bool topoSort(int n) {...
分类:其他好文   时间:2014-08-02 10:07:43    阅读次数:196
UVa 11078 Open Credit System
本题可以边读边计算,MaxAi用来维护已经读入的数据的最大值,然后每次读入一个num,就计算一次MaxAi-num,如果比ans更大,就更新ans。 1 //#define LOCAL 2 #include 3 #include 4 #include 5 using namespace std...
分类:其他好文   时间:2014-08-02 09:55:03    阅读次数:169
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!