A

模拟题

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int maxn = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
const int turn2[][] = {{, }, { -, }, {, }, {, -}, {, -}, { -, -}, {, }, { -, }};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int main()
{
double h, m, C;
cin >> h >> m;
int H, D, N;
cin >> H >> D >> C >> N;
double ans = ;
double duce = ;
if (h < )
{
duce = 1.0 * ( - h) * - m;
}
else
{
C = 0.8 * C;
}
int need = H / N + ( - (H % N == ));
double ans1 = 1.0 * need * C;
if (duce != )
{
H += D * duce;
C = 0.8 * C;
need = H / N + ( - (H % N == ));
ans = need * C;
printf("%.4f\n", min(ans, ans1));
}
else
{
printf("%.4f\n", ans1);
}
}

B

阅读理解

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int ch[];
int main()
{
int sum = ;
string a;
cin >> a;
for (int i = ; i < a.size(); i++)
{
if (ch[a[i] - 'a'] == )
{
sum++;
}
ch[a[i] - 'a']++;
}
if (sum > )
{
cout << "No" << endl;
return ;
}
if (sum == )
{
cout << "Yes" << endl;
}
else if (sum == )
{
for (int i = ; i <= ; i++)
{
if (ch[i] > )
{
cout << "Yes" << endl;
return ;
}
}
cout << "No" << endl;
}
else if (sum == )
{
for (int i = ; i <= ; i++)
{
if (ch[i] == )
{
cout << "No" << endl;
return ;
}
}
cout << "Yes" << endl;
}
else
{
cout << "No" << endl;
}
return ;
}

C

给你Q(1~1e5)个询问 每个询问有L,R(1~1e18)

问你L~R之间有多少个"good number"  “good number"是a^p的数 a>0 p>1

因为总共有1e18个数 所以当p固定时 就有10^(18/p)个数 当p为2的时候很大 特殊处理 二分枚举checkL和R的sqrt得到答案

再来处理3~60部分(因为2^60>1e18)的答案 因为最大的10^(18/3)只有1e6所以可以全部枚举出来再nlogn排序去重 预处理复杂度为nlogn

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int maxn = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
const int turn2[][] = {{, }, { -, }, {, }, {, -}, {, -}, { -, -}, {, }, { -, }};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll nowmaxn = 1e18;
ll anser1;
ll anser2;
ll num[];
int pop = ;
//ll qpow(ll a, ll b)
//{
// ll ans = 1, base = a;
// while (b != 0)
// {
// if (b & 1 != 0)
// {
//   ans *= base;
// }
// base *= base;
// b >>= 1ll;
//  
// }
// return ans;
//}
bool judge(ll x)
{
ll s = sqrt(x);
for (ll i = s; i <= s + ; i++)
{
if (1LL * i * i == x)
{
return true;
}
}
return false;
}
void init()
{
ll now;
ll limit;
for (ll i = ; i <= ; i++)
{
limit = nowmaxn / i;
now = 1LL * i * i;
for (ll j = ;; j++)
{
now = 1LL * i * now;
if (!judge(now))
{
num[pop++] = now;
}
if (now > limit)
{
break;
}
}
}
sort(num + , num + pop);
pop = unique(num + , num + pop) - num;
}
ll gettwo(ll x)
{
ll ans;
ll l = ;
ll r = 2e9;
while (l < r - )
{
ll mid = (l + r) >> ;
if (mid * mid <= x)
{
l = mid;
}
else
{
r = mid;
}
}
return l;
}
int main()
{
init();
// for (int i = 1; i <= 10; i++)
// {
// cout << num[i] << " ";
// }
// cout << endl;
ll L, R;
int q;
cin >> q;
for (int i = ; i <= q; i++)
{
anser1 = anser2 = ;
scanf("%lld %lld", &L, &R);
if (L == )
{
anser1++;
}
anser1 = gettwo(R) - gettwo(L - );
//cout << anser1 << endl;
int L1 = lower_bound(num + , num + pop, L) - num;
int R1 = lower_bound(num + , num + pop, R) - num;
//cout << " " << L1 << " " << R1 << endl;
if (L1 == R1)
{
if (num[L1] == R)
{
anser2++;
}
}
else
{
anser2 = R1 - L1 + (num[R1] == R);
}
cout << anser1 + anser2 << endl;
}
}

Codeforces 955 LR询问 多次幂处理的更多相关文章

  1. codeforces magic five --快速幂模

    题目链接:http://codeforces.com/contest/327/problem/C 首先先算出一个周期里面的值,保存在ans里面,就是平常的快速幂模m做法. 然后要计算一个公式,比如有k ...

  2. CodeForces - 691E Xor-sequences 【矩阵快速幂】

    题目链接 http://codeforces.com/problemset/problem/691/E 题意 给出一个长度为n的序列,从其中选择k个数 组成长度为k的序列,因为(k 有可能 > ...

  3. Codeforces 963 A. Alternating Sum(快速幂,逆元)

    Codeforces 963 A. Alternating Sum 题目大意:给出一组长度为n+1且元素为1或者-1的数组S(0~n),数组每k个元素为一周期,保证n+1可以被k整除.给a和b,求对1 ...

  4. Codeforces 691E题解 DP+矩阵快速幂

    题面 传送门:http://codeforces.com/problemset/problem/691/E E. Xor-sequences time limit per test3 seconds ...

  5. 【codeforces 623E】dp+FFT+快速幂

    题目大意:用$[1,2^k-1]$之间的证书构造一个长度为$n$的序列$a_i$,令$b_i=a_1\ or\ a_2\ or\ ...\ or a_i$,问使得b序列严格递增的方案数,答案对$10^ ...

  6. Codeforces 691E Xor-sequences(矩阵快速幂)

    You are given n integers a1,  a2,  ...,  an. A sequence of integers x1,  x2,  ...,  xk is called a & ...

  7. codeforces 696C C. PLEASE(概率+快速幂)

    题目链接: C. PLEASE time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  8. Codeforces 954 dijsktra 离散化矩阵快速幂DP 前缀和二分check

    A B C D 给你一个联通图 给定S,T 要求你加一条边使得ST的最短距离不会减少 问你有多少种方法 因为N<=1000 所以N^2枚举边数 迪杰斯特拉两次 求出Sdis 和 Tdis 如果d ...

  9. [Luogu3242][HNOI2015]接水果

    Luogu 我今天做两道整体二分结果全都是BZOJ权限题??? sol 我们抓住"盘子的路径是水果的路径的子路径"这个条件. 考虑每一个盘子路径\((u,v)\),讨论它可以作为哪 ...

随机推荐

  1. 吃着火锅唱着歌学会Docker

    第一篇:Docker概述 第二篇:Docker之版本与安装 第三篇:Docker之镜像 第四篇:Docker之容器 第五篇:Dcoker之容器与镜像 第六篇:Docker之网络管理 第七篇:Docke ...

  2. redis--迁库操作

    如果碰到redis库要迁移(之前的redis用作他用)或者备份用,就需要操作redis迁移 import redis def qianyi(k=None,v=None,name=None): r1 = ...

  3. 使用xampp和HBuilder搭建php环境

    1.首先你的电脑里面要有两个软件  xampp 和 HBuilder xampp: HBuilder: 这两个软件都是免费的,在安装过程中也无需费力,只要设置好路径就行了. 在xampp安装过程中,需 ...

  4. 阶段3 1.Mybatis_05.使用Mybatis完成CRUD_7 Mybatis中参数的深入-使用实体类的包装对象作为查询条件

    pojo对象就是实体类 综合查询-实体类包装起来做查询 新建实体类QueryVo 提供一个User对象属性,并生成getter和setter 测试 修改dao接口中的返回类型为List<User ...

  5. TCP 首部格式

    <图解TCP/IP> 6.7  TCP的首部格式 TCP中没有表示包长度和数据长度的字段.可由IP层获知TCP的包长由TCP的包长可知数据的长度. 源端口号:表示发送端端口号,字段长16位 ...

  6. gitlab+jenkins 搭建

    继前一篇gitlab,这一篇介绍jenkins搭建并与gitlab进行集成---这里不是详细的步骤 环境系统:centos 7.3 jenkins版本:jenkins-2.176.1-1.1.noar ...

  7. bigdata数据分析(二):关闭防火墙&安装telnet

    先检查CentOS7.0是否已经安装以下两个安装包:telnet-server.xinetd.命令如下: rpm -qa telnet-server rpm -qa xinetd 如果没有安装,则先安 ...

  8. 深入理解java:2.3.1. 并发编程concurrent包 之Atomic原子操作(循环CAS)

    java中,可能有一些场景,操作非常简单,但是容易存在并发问题,比如i++, 此时,如果依赖锁机制,可能带来性能损耗等问题, 于是,如何更加简单的实现原子性操作,就成为java中需要面对的一个问题. ...

  9. 红帽学习笔记[RHCSA] 第七课[网络配置相关]

    第七课[网络配置相关] 在Vmware中添加网卡 编辑 -> 编辑虚拟网络 -> 添加网络->随便选择一个如VMnet2-> 选择仅主机模式 -> 勾掉使用本地DHCP服 ...

  10. Highways POJ-1751 最小生成树 Prim算法

    Highways POJ-1751 最小生成树 Prim算法 题意 有一个N个城市M条路的无向图,给你N个城市的坐标,然后现在该无向图已经有M条边了,问你还需要添加总长为多少的边能使得该无向图连通.输 ...