暴力出奇迹。。

#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. Java Thread 那些事

    这篇文章被压在草稿箱许久,最近公司内部的技术社区有同学贴出了几篇分享 Java线程的文章,发觉有很多概念没有讲清楚,所以花点时间继续撰写,便有了这篇博文. 本文只聚焦 JVM 层面的线程模型,不考虑和 ...

  2. 配置VS2008下的Qt开发环境有感

    写一篇小小的日志为了在VS2008中安装Qt的插件,花了我很多的时间.1.vs2008在win7中破解问题我的VS2008已经安装好了,不知道为何,当初没有破解,现在只剩下15天限制了.于是为了破解, ...

  3. HDU 4070 Phage War

    贪心,t 大的放到前面...因为感染所有cell需要的phage的总数是一定的,所以产生phage需要的时间是一定的,只需要考虑用来感染的时间,这样考虑的话,把 t 小的放后面的话,可以发现总时间的最 ...

  4. FZU 1894 (双端队列)

    Problem 1894 志愿者选拔 Accept: 1166    Submit: 3683 Time Limit: 1500 mSec    Memory Limit : 32768 KB  Pr ...

  5. find: paths must precede expression(转)

    find: paths must precede expressionUsage: find [-H] [-L] [-P] [path...] [expression] 然后就上网查了一下,结果搜索到 ...

  6. hdu 5138

    参考……!!!! #include <iostream> #include <cstdio> #include <cmath> #include <cstri ...

  7. HDOJ 4883 TIANKENG’s restaurant

    称号: TIANKENG's restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Ja ...

  8. Swift - 使用xib添加新界面

    除了使用storyboard外,我们还可以使用xib来设计并创建页面. 1,下面通过一个样例来演示: (1)点击主界面的“信息”按钮,页面切换到信息界面 (2)点击信息界面的“返回”,关闭信息界面,回 ...

  9. 与众不同 windows phone (17) - Graphic and Animation(画图和动画)

    原文:与众不同 windows phone (17) - Graphic and Animation(画图和动画) [索引页][源码下载] 与众不同 windows phone (17) - Grap ...

  10. form表单多值提交

    $.ajax({ cache: true, type: "POST", url:ajaxCallUrl, data:$('#yourformid').serialize(),// ...