"字节跳动杯"2018中国大学生程序设计竞赛-女生专场
口算训练
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = 1e5 + ;
using namespace std;
const int MOD = 1e9+;
typedef long long ll; vector<int> g[maxn];
//下标肯定是从小到大按顺序的 void res(int id, int x){
for(int i = ;i*i <= x;i++){
while(x%i == ){
g[i].push_back(id);
x /= i;
}
}
if(x > )
g[x].push_back(id);
} int query(int l,int r, int x){
return upper_bound(g[x].begin(), g[x].end(), r) - lower_bound(g[x].begin(),g[x].end(), l);
} void init(){
for(int i = ;i < maxn;i++)
g[i].clear();
} int main(){
// Faster;
int t;
// cin >> t;
scanf("%d", &t);
while(t--){
init();
int n, q;
scanf("%d%d", &n, &q);
for(int i = ;i <= n;i++){
int x;
// cin >> x;
scanf("%d", &x);
res(i, x);
}
while(q--){
int l, r, d, num;
// cin >> l >> r >> d;
scanf("%d%d%d", &l, &r, &d);
bool ok = true;
for(int i = ;i*i <= d;i++){
int cnt = ;
while(d%i == ){
cnt++;
d /= i;
}
//因子为i 的数目 大于(l,r)中i 的个数
num = query(l, r, i);
if(cnt > num){
ok = false;
break;
}
}
if(ok && d > ){
num = query(l, r, d);
if(num == )
ok = false;
}
if(ok)
// cout << "Yes" << endl;
printf("Yes\n");
else
// cout << "No" << endl;
printf("No\n");
}
}
return ;
}
缺失的数据范围
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = 1e4 + ;
using namespace std;
const int MOD = 1e9+;
typedef unsigned long long ll; int a, b;
ll k; bool check(ll x){
long double ans = ;
for(int i = ;i < a;i++){
ans *= x;
if(ans > k)
return false;
}
ll bb = ceil(log2(x));
for(int i = ;i < b;i++){
ans *= bb;
if(ans > k)
return false;
}
return true;
} int main(){
Faster;
int n;
cin >> n;
while(n--){
cin >> a >> b >> k;
ll l = ;
ll r = k;
while(l <= r){
ll mid = (l+r)/;
if(check(mid)){
l = mid+;
}
else{
r = mid-;
}
}
cout << r << endl;
}
return ;
}
赛题分析
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = 1e4 + ;
using namespace std;
const int MOD = 1e9+;
typedef long long ll; #define INF 0xfffffff int main(){
Faster;
int t;
cin >> t;
int cnt = ;
while(t--){
int n, m;
cin >> n >> m;
int Min1 = INF;
int Min2 = INF;
for(int i = ;i < n;i++){
int x;
cin >> x;
if(x < Min1){
Min1 = x;
}
}
for(int i = ;i < m;i++){
int x;
cin >> x;
if(x < Min2){
Min2 = x;
}
}
cout << "Problem " << ++cnt << ":" << endl;
cout << "Shortest judge solution: " << Min1 << " bytes." << endl;
if(Min2 == INF)
cout << "Shortest team solution: N/A bytes." << endl;
else
cout << "Shortest team solution: " << Min2 << " bytes." << endl;
}
return ;
}
SA-IS后缀数组
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = 1e4 + ;
using namespace std;
const int MOD = 1e9+;
typedef long long ll; int main(){
Faster;
int t;
cin >> t;
while(t--){
int n;
cin >> n;
string s;
cin >> s;
int cnt = ;
for(int i = ;i < n-;i++){
if(s[i] == s[i+]){
cnt++;
}
else if(s[i] < s[i+]){
cnt++;
while(cnt){
cnt--;
cout << "<";
}
}
else if(s[i] > s[i+]){
cnt++;
while(cnt){
cnt--;
cout << ">";
}
}
}
while(cnt--){
cout << ">";
}
cout << endl;
}
return ;
}
"字节跳动杯"2018中国大学生程序设计竞赛-女生专场的更多相关文章
- "字节跳动杯"2018中国大学生程序设计竞赛-女生专场 Solution
A - 口算训练 题意:询问 $[L, R]$区间内 的所有数的乘积是否是D的倍数 思路:考虑分解质因数 显然,一个数$x > \sqrt{x} 的质因子只有一个$ 那么我们考虑将小于$\sqr ...
- 2017中国大学生程序设计竞赛 - 女生专场 Deleting Edges(思维+最短路)
Deleting Edges Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 2017中国大学生程序设计竞赛 - 女生专场 Happy Necklace(递推+矩阵快速幂)
Happy Necklace Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 2017中国大学生程序设计竞赛 - 女生专场(Graph Theory)
Graph Theory Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)To ...
- 2017中国大学生程序设计竞赛 - 女生专场(dp)
Building Shops Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) To ...
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场
Combine String #include<cstdio> #include<cstring> #include<iostream> #include<a ...
- hdu_5705_Clock("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5705 题意:给你一个时间和一个角度,问你下一个时针和分针形成给出的角度是什么时候 题解:我们可以将这个 ...
- hdu_5707_Combine String("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5707 题意:给你三个字符串 a,b,c,问你 c能否拆成a,b,a,b串的每一个字符在c中不能变 题解 ...
- HDU 6024(中国大学生程序设计竞赛女生专场1002)
这是CCPC女生专场的一道dp题.大佬们都说它简单,我并没有感到它有多简单. 先说一下题意:在一条直线上,有n个教室,现在我要在这些教室里从左到右地建设一些作为糖果屋,每个教室都有自己的坐标xi 和建 ...
随机推荐
- 【洛谷 2405】 non天平
题目背景 non最近正在为自己的体重而苦恼,他想称量自己的体重.于是,他找来一个天平与许多砝码. 题目描述 砝码的重量均是n的幂次,n^1.n^2.n^3.n^4.n^5的……non想知道至少要多少个 ...
- codeforces A. Array 解题报告
题目链接:http://codeforces.com/problemset/problem/300/A 题目意思:给出n个数,将它们分成三批:1.所有数相乘的结果 < 0 2.所有数相乘的 ...
- 【转载】malloc和new
1.malloc与free是C++/C语言的标准库函数,new/delete是C++的运算符.它们都可用于申请动态内存和释放内存2.对于非内部数据类型的对象而言,光用maloc/free无法满足动态对 ...
- 「NOIP2002」「Codevs1099」 字串变换(BFS
1099 字串变换 2002年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 已知有两个字串 $A$, ...
- Linux终端程序用c语言实现改变输出的字的颜色
颜色代码: 格式: echo "\033[字背景颜色;字体颜色m字符串\033[0m" 例如: echo "\033[41;36m something here \033 ...
- PYTHON 异常处理 一 ASSERT
assert语句,如果没记错,这个东西在C或者C++里面也有的.属于短小的断言.下面的是来自python help document的说明: Assert statements are a conve ...
- CSS元素:clip属性作用说明
clip属性是一个比较有用的属性,但往往在实际应用中,并不多见,介绍的也很少.应用clip属性需要注意的两点: 一.clip属性必须和定位属性postion一起使用才能生效. 二.clip裁切的计算坐 ...
- Android开发技巧--引用另一个工程
现在已经有了一个Android工程A.我们想扩展A的功能,但是不想在A的基础上做开发,于是新建了另外一个Android工程B,想在B中引用A. 1:把工程A做成纯Jar包,这样其他的工程就可以直接引用 ...
- MongoDB -- 安装(win 10)
1. 下载安装包: mongodb-win32-x86_64-2008plus-ssl-4.0.10-signed.msi https://www.mongodb.com/download-cente ...
- P-Function
题意: 对于集合 $S = {1, 2, ...., n}$ , 定义函数 $F(x) = y, x, y$ 属于 $S$,对于任何 $x$ 属于 $S$, 有 $F(F...F(x)) = x$, ...