"字节跳动杯"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 和建 ...
随机推荐
- ZOJ - 3932 Handshakes 【水】
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3932 题意 给出 N 个人,然后 1-N 然后 从 1 - N ...
- 人生苦短之Python装饰器
在Python中函数也是一个对象,我们可以获得函数对象,然后执行函数 def func(): print('I am very good') a = func a 如果我们要是想增强这个函数呢?比如给 ...
- HTML layout高仿QQ GUI
1. [图片] QQ20130804162049.png 2. [代码]AAuto 代码 import win.ui;import web.layout;/*DSG{{*/winform = ...
- BZOJ 1624 [Usaco2008 Open] Clear And Present Danger 寻宝之路:floyd
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1624 题意: 农夫约翰正驾驶一条小艇在牛勒比海上航行. 海上有N(1≤N≤100)个岛屿, ...
- DB2删除表分区
近日,由于部门数据库读库空间过小,提出删除掉两个月之前日志表的分区(数据库分区是按时间月分区),记述如下: 上网搜索资料发现删除表分区大概分这么几步: 1.查询需要删除掉的分区: select t.D ...
- 并不对劲的BJOI2019
一些感想 现实并非游戏,并不支持反复刷关 猎人和防御工事一起被老山龙摧毁了: 猎人惨死雨中,结云村永无放晴之日: 猎人被狂龙病毒侵蚀,天空山上黑蚀龙泛滥. 好像这才是怪物猎人系列的真实结局呢 day ...
- MongoDB复制集成员及架构介绍(一)
MongoDB复制集介绍 MongoDB支持在多个机器中通过异步复制达到提供了冗余,增加了数据的可用性.MongoDB有两种类型的复制,第一种是同于MySQL的主从复制模式(MongoDB已不再推荐此 ...
- alsa音频驱动框架
sound/core/sound.c 实现了最顶层的file_operations,它起中转作用 sound/core/control.c 实现了控制接口的file_operations sound/ ...
- 4月超棒的JavaScript游戏开发框架推荐(1) – 51CTO.COM
基于JavaScript开发的游戏是唯一一个能够跨桌面,Web和移动三种平台的.… 查阅全文 ›
- java.lang.NoSuchMethodError: org.springframework.core.io.ResourceEditor错误
一般是jar包冲突,或者某些jar包版本不同. 如上,spring其他包的版本均为4.2.5,而spring-webmvc的jar包为1.2.6版本,造成版本冲突. 把该包版本改为4.2.5,宣告成功 ...