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 模拟题,布布扣,bubuko.com

时间: 2024-07-29 12:45:31

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

HDU 4022 Bombing STL 模拟题

手动模拟.. #include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<cmath> #include<queue> #include<set> #include<map> using namespace std; #define N 10100 #define inf 1000000010 map<

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

Fighting the Landlords 大意: 斗地主....   分别给出两把手牌,肯定都合法.每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Black & White Joker) > 2 > A (Ace) > K (King) > Q (Queen) > J (Jack) > T (10) > 9 > 8 > 7 > 6 > 5 > 4 > 3. 给你8种组合:1.

HDU 4772 Zhuge Liang&#39;s Password (简单模拟题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4772 题面: Zhuge Liang's Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1404    Accepted Submission(s): 926 Problem Description In the anc

HDU 4028 The time of a day(动态规划)

The time of a day Problem Description There are no days and nights on byte island, so the residents here can hardly determine the length of a single day. Fortunately, they have invented a clock with several pointers. They have N pointers which can mo

hdu 5641 King&#39;s Phone(暴力模拟题)

Problem Description In a military parade, the King sees lots of new things, including an Andriod Phone. He becomes interested in the pattern lock screen. The pattern interface is a 3×3 square lattice, the three points in the first line are labeled as

HDU 1048 What Is Your Grade? (简单模拟)

 What Is Your Grade? Problem Description "Point, point, life of student!" This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in

hdu 1012:u Calculate e(数学题,水题)

u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28686    Accepted Submission(s): 12762 Problem Description A simple mathematical formula for e iswhere n is allowed to go to infinit

hdu 5621 KK&#39;s Point(数学,推理题)

题解: 在圆上点三个点时,除圆上三个交点外,圆内没有交点:在圆上点四个点时,除圆上四个交点外,圆内出现了一个交点,因此,在N个点中每四个点便可以在圆内产生一个交点,因此N个点在圆内形成的点的个数为CN4,总的交点数就是CN4+N 1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include<iostream> 3 #include<cstdio> 4 #include<cstrin

HDU 5135 Little Zu Chongzhi&#39;s Triangles(简单水题)

题目链接: 戳我 题目大意: 给一堆 木棍,用这些木棍组成三角形,要组成的所有的三角形的面积和最大,不一定要用完所有的木棍. 样例解释: 3 //三个棍子 1 1 20   // 每个棍子的长度,自然,这三个棍子不可能组成三角形,故输出 0.00 7          // 7个棍子 3 4 5 3 4 5 90 // 组成两个三角形(3, 3 4)和(4, 4, 5),面积和即为13.64 0   // 输出 0 退出 解题思路: 本来不想写题解的,因为太水了,,,,,,, 可是看到 谷歌搜出