暴力出奇迹。。

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll __int64
#define N 42
ll n,m,ans;
ll Gcd(ll x,ll y){
if(x>y)swap(x,y);
while(x){
y%=x;
swap(x,y);
}
return y;
}
ll Lcp(ll x,ll y){return x*y/Gcd(x,y);}
map<ll,ll>mp[N];
map<ll,ll>::iterator p;
pair<ll,ll>tmp;
void work(ll x, ll cur){
p = mp[cur].end();
if(p==mp[cur].begin())return;
p--;
for(;;p--){
tmp = *p;
ll dou = Lcp(tmp.first,x);
if(dou>=m){
ans += tmp.second;
}
mp[cur][dou]+=tmp.second;
if(p==mp[cur].begin())return;
}
}
struct node{
ll num, ans;
bool operator<(const node&a)const{
return a.num>num;
}
};
set<node>myset[N];
int main(){
ll i, j, Cas = 1, T;scanf("%I64d",&T);
mp[0].clear();
for(i=1;i<=40;i++)
{
mp[i] = mp[i-1];
work(i,i);
mp[i][i]++;
node now = {0,0};
myset[i].clear();
for(p=mp[i].end(),p--;;p--){
tmp = *p;
now.num = tmp.first;
now.ans += tmp.second;
myset[i].insert(now);
if(p==mp[i].begin())break;
}
}
while(T--){
scanf("%I64d %I64d",&n,&m);
printf("Case #%I64d: ",Cas++);
node dou = {m,-1};
if(myset[n].lower_bound(dou)==myset[n].end())puts("0");
else printf("%I64d\n",myset[n].lower_bound(dou)->ans);
}
return 0;
}

HDU 4028 The time of a day STL 模拟题的更多相关文章

  1. HDU 4022 Bombing STL 模拟题

    人工模拟.. #include<stdio.h> #include<iostream> #include<algorithm> #include<vector ...

  2. HDU 4930 Fighting the Landlords(扯淡模拟题)

    Fighting the Landlords 大意: 斗地主... . 分别给出两把手牌,肯定都合法.每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Black ...

  3. stl+模拟 CCF2016 4 路径解析

    // stl+模拟 CCF2016 4 路径解析 // 一开始题意理解错了.... #include <iostream> #include <string> #include ...

  4. 【STL+模拟】UVa 506 - System Dependencies

    System Dependencies  Components of computer systems often have dependencies--other components that m ...

  5. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

  6. hdu 5288||2015多校联合第一场1001题

    pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...

  7. HDU 1004 Let the Balloon Rise【STL<map>】

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  8. [HDU 4666]Hyperspace[最远曼哈顿距离][STL]

    题意: 许多 k 维点, 求这些点之间的最远曼哈顿距离. 并且有 q 次操作, 插入一个点或者删除一个点. 每次操作之后均输出结果. 思路: 用"疑似绝对值"的思想, 维护每种状态 ...

  9. hdu 4028 2011上海赛区网络赛H dp+map离散

    一开始用搜索直接超时,看题解会的 #include<iostream> #include<cstdio> #include<map> #include<cst ...

随机推荐

  1. android的单元测试

    1.新建android Test project 2. 选择针对测试的项目 3.新建类继承AndroidTestCase即可: package com.howlaa.sms.test; import ...

  2. Codeforces Round #306 (Div. 2) D.E. 解题报告

    D题:Regular Bridge 乱搞. 构造 这题乱搞一下即可了.构造一个有桥并且每一个点的度数都为k的无向图. 方法非常多.也不好叙述.. 代码例如以下: #include <cstdio ...

  3. OpenCV编程-&gt;Windows7下调用iPhnoe摄像头

    //////////////////////////////////////////////////////////////  指尖热度原创,转载请注明来自http://blog.csdn.net/s ...

  4. Get Cordova Ready for Grunt and CoffeeScript

    Cordova, Grunt and Coffee You may reference to below if you deside to work with coffee instead of Ja ...

  5. JSP的学习(2)——语法知识一

    上一篇<JSP的学习>讲述了JSP的一些基础知识和底层原理,本篇将来学习JSP所需掌握的语法知识等. JSP的语法主要包括以下几个部分的内容: 1)         JSP模板元素 2)  ...

  6. kernel hexdump分析

    驱动调试中,很多时候是二进制的,这个时候hexdump就是个非常有用的工具了. 不要再自己去实现类似的功能,kernel代码里面就有: 参考: kernel/lib/hexdump.c // 0Xxx ...

  7. 11661 - Burger Time?

      Burger Time?  Everybody knows that along the more important highways there are countless fast food ...

  8. uva 11400 Problem F Lighting System Design

    紫皮书题: 题意:让你设计照明系统,给你n种灯泡,每种灯泡有所需电压,电源,每个灯泡的费用,以及每个灯泡所需的数量.每种灯泡所需的电源都是不同的,其中电压大的灯泡可以替换电压小的灯泡,要求求出最小费用 ...

  9. javascript (九)注释

    单行注释,采用双斜杠  // 多行注释,采用 /* */

  10. 积累的VC编程小技巧之树操作

    1.如何在TreeList中加图标? [问题提出]  请问treeview控件和treectrl控件的用法有何不同呢?向如何imagelist控件中加图象呀?  [解决方法]  1)    HICON ...