博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 4028 The time of a day STL 模拟题
阅读量:7046 次
发布时间:2019-06-28

本文共 1303 字,大约阅读时间需要 4 分钟。

暴力出奇迹。。

#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;#define ll __int64#define N 42ll 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
mp[N];map
::iterator p;pair
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
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;}


本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5088444.html,如需转载请自行联系原作者

你可能感兴趣的文章
数制系统
查看>>
cmd连接mysql操作命令
查看>>
“2017最受欢迎中国开源软件”奖TOP 20揭晓 阿里中间件4大项目连续霸榜!
查看>>
Log4j 配置 的webAppRootKey参数问题
查看>>
第 14 章 MyBatis
查看>>
176.6. git-svn - Bidirectional operation between a single Subversion branch and git
查看>>
linux中授予普通用户root权限
查看>>
我的架构之路 — 配置中心(二)— 在已有项目中实际应用
查看>>
分布式监控系统Zabbix3.2对数据库的连接数预警
查看>>
undo表空间文件丢失恢复(1)--有备份
查看>>
[20151017]lsnrctl servcices.txt
查看>>
使用JustDecompile修改程序集
查看>>
Fastjson 专题
查看>>
SQL导入txt以及SQL中的时间格式操作
查看>>
各种ESB产品比较(转)
查看>>
Android Drawable绘图学习笔记(转)
查看>>
给PLSQL插上飞翔的翅膀-PLSQL优化
查看>>
手把手教你如何在阿里云服务器上搭建PHP环境?
查看>>
经典悖论之-意料之外的考试
查看>>
【FFMpeg视频开发与应用基础】一、使用FFmpeg命令行工具和批处理脚本进行简单的音视频文件编辑...
查看>>