HDU 4028 The time of a day STL 模拟题
暴力出奇迹。。
#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 模拟题的更多相关文章
- HDU 4022 Bombing STL 模拟题
人工模拟.. #include<stdio.h> #include<iostream> #include<algorithm> #include<vector ...
- HDU 4930 Fighting the Landlords(扯淡模拟题)
Fighting the Landlords 大意: 斗地主... . 分别给出两把手牌,肯定都合法.每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Black ...
- stl+模拟 CCF2016 4 路径解析
// stl+模拟 CCF2016 4 路径解析 // 一开始题意理解错了.... #include <iostream> #include <string> #include ...
- 【STL+模拟】UVa 506 - System Dependencies
System Dependencies Components of computer systems often have dependencies--other components that m ...
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
- hdu 5288||2015多校联合第一场1001题
pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...
- 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 ...
- [HDU 4666]Hyperspace[最远曼哈顿距离][STL]
题意: 许多 k 维点, 求这些点之间的最远曼哈顿距离. 并且有 q 次操作, 插入一个点或者删除一个点. 每次操作之后均输出结果. 思路: 用"疑似绝对值"的思想, 维护每种状态 ...
- hdu 4028 2011上海赛区网络赛H dp+map离散
一开始用搜索直接超时,看题解会的 #include<iostream> #include<cstdio> #include<map> #include<cst ...
随机推荐
- WCF消息之XmlDictionaryWriter
原文:WCF消息之XmlDictionaryWriter XmlDictionaryWriter,是一个抽象类,从该类中派生了WCF,以便执行序列化和反序列化. 它有4种格式书写器: CreateBi ...
- 单选按钮、复选按钮——axure线框图部件库介绍
有时候发现这做事情坚持下来是一件很不容易的,写教程也一样,不过听到很多朋友对我说 这个全部是图片的教程 对他们入门帮助很多,我就想想 在坚持坚持把基础部分先完善了! 1. 简单的问卷调查: 您的性别? ...
- [Warning] Aborted connection 11203 to db: 'ide' user: 'nuc' host: 'prd01.mb.com' (Got an error writi
PS:一台物理机扯分了3个虚拟机,一个主db,一个主备,一个从备. 切换到0301的时候 Sep 6 09:16:16 prddb0301 mysqld: 130906 9:16:16 [Warn ...
- Linux 下获取LAN中指定IP的网卡的MAC(物理地址)
// all.h// 2005/06/20,a.m. wenxy #ifndef _ALL_H#define _ALL_H #include <memory.h>#include < ...
- 微信支付[v3]
原文:微信支付[v3] V2升级V3 顺便记录一下 ,文档: http://pay.weixin.qq.com/wiki/doc/api/index.html !!! 支付授权目录与测试人的微信帐号白 ...
- 基于Spring提供支持不同设备的页面
基于Spring来检测访问Web页面的设备是很简单的,在这个经验中我们讲到过.通常不同的设备访问我们是通过响应式设计来统一处理各种设备的尺寸的.但是如果希望针对不同的设备,显示不同的内容呢? Spri ...
- 关键部分CCriticalSection使用
类CCriticalSection的对象表示一个“临界区”,它是一个用于同步的对象,同一时刻仅仅同意一个线程存取资源或代码区.临界区在控制一次仅仅有一个线程改动数据或其他的控制资源时很实用.比如,在链 ...
- http2.0笔记
二进制分帧层 定义了如何封装 HTTP 消息并在客户端与服务器之间传输 http2.0的消息传输特点: 流 已建立的连接上的双向字节流 消息 与逻辑消息对应的完整的一系列数据帧 帧 http2.0通信 ...
- Lucene.Net 2.3.1开发介绍 —— 简介
原文:Lucene.Net 2.3.1开发介绍 -- 简介 Lucene.Net是Lucene在dot net平台上的移植版本.它的功能与Lucene一样,都是用来提供一组API,让我们能快速开发自己 ...
- win 7 设置防火墙例外的端口号, 让其域网中可以访问
背景,发布 一个tomcat下的website, 而发局域网可以访问. 这时,可以关闭防火墙:或者开启防火墙,并设置一个防火墙的入站规则,让身边的同事访问这个website. 设置方法:win 7 - ...