The 2019 University of Jordan Collegiate Programming Contest
链接:https://codeforc.es/gym/102267
A. Picky Eater
直接比较
int main(){
int x ,y;
scanf("%d %d" ,&x ,&y);
if(x>=y){
return printf(""),;
}
else return printf(""),;
return ;
}
B. Primes
素数筛,log判断
int prime[maxn],num_prime = ;
int vis[maxn];
void is_prime(int N){
for(int i=;i<=N;i++){
if(!vis[i]){
prime[num_prime++] = i;
vis[i] = i;
}
for(int j=;j<num_prime&&i*prime[j]<=N;j++){
vis[i*prime[j]] = prime[j];
if(!(i%prime[j])){
break;
}
}
}
return;
}
int n;
int main(){
scanf("%d", &n);
is_prime(n);
for(int i = ; i < num_prime; i++){
int j = prime[i];
int p = lower_bound(prime,prime+num_prime,n-j)-prime;
if(prime[p]==n-j){
return printf("%d %d",j,n-j),;
} }
printf("-1");
return ;
}
C. Matryoshka Dolls
一个循环
int x,y;
int main(){
scanf("%d %d", &x, &y);
int ans = ;
while(x){
ans++;
x/=y;
}printf("%d",ans);
return ;
}
D. Robots Easy
12*12,直接rand乱跑
#include<iostream>
#include<cstdio>
#include<algorithm>
//#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1 using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = ;
const int maxn = 2e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
//const db pi = acos(-1.0); int x,y;
int a[][];
vector<char>ans;
int dx,dy;
inline int Rand(){
static int seed = ;
return seed = (int)((((seed ^ ) + 19260817ll) * 19890604ll) % );
}
int main(){
int t;
scanf("%d", &t);
a[][]=a[][]=a[][]=a[][]=;
a[][]=a[][]=a[][]=;
a[][]=a[][]=a[][]=;
a[][]=a[][]=a[][]=a[][]=;
while(t--){
ans.clear();
scanf("%d %d" ,&x ,&y);
while(a[x][y]!=){
//printf("%d %d\n",x,y);
int op;
while(op=rand()%){
dx=dy=;
char ch;
if(op==){dx=-;ch='U';}
if(op==){dx=;ch='D';}
if(op==){dy=-;ch='L';}
if(op==){dy=;ch='R';}
if(op==)continue;
//printf(" %d\n",op);
if(x+dx>=&&x+dx<=&&y+dy>=&&y+dy<=){
if(a[x+dx][y+dy]==)continue;
x+=dx;y+=dy;
ans.pb(ch);
break;
}
else continue;
}
}
printf("%d\n",ans.size());
for(int i = ; i < (int)ans.size(); i++){
printf("%c",ans[i]);
}printf("\n"); }
return ;
}
H. Circle of Polygon
一个公式
double v,s;
int main(){
scanf("%lf %lf", &v, &s);
printf("%.9lf",1.0/2.0*pi*s*s/(1.0-cos(*pi/v))); return ;
}
I. Ultimate Army
左括号之后一定跟一个数,遇到左括号,下一个数的sup就是栈顶,遇到数字入栈,遇到右括号出栈
int n;
char a[maxn];
stack<int>s;
vector<int>v;
int ans[maxn];
int main(){
scanf("%d", &n);
scanf("%s",a+);
int len = strlen(a+);
int tmp = ;
int gao = ;
for(int i = ; i <= len; i++){
if(a[i]>=''&&a[i]<=''){
tmp*=;
tmp+=a[i]-'';
}
else{
if(tmp!=)v.pb(tmp);
tmp=;
}
if(a[i]=='(')v.pb(-);
else if(a[i]==')')v.pb(-);
}
for(int i = ; i < (int)v.size(); i++){
if(v[i]>){
if(gao)ans[v[i]]=s.top();
s.push(v[i]);
gao=;
}
else if(v[i]==-){
gao=;
}
else if(v[i]==-){
s.pop();
}
}
for(int i = ; i <= n; i++){
printf("%d ",ans[i]);
}
return ;
}
K. Birthday Puzzle
2^20暴力dfs维护答案即可
ll ans;
int n;
int a[maxn];
void dfs(int x, int now){
if(x==n+){
ans+=now;
return;
}
dfs(x+,now|a[x]);
dfs(x+,now);
}
int main(){
scanf("%d", &n);
for(int i = ; i <= n; i++){
scanf("%d", &a[i]);
}
dfs(,);
printf("%lld",ans);
return ;
}
The 2019 University of Jordan Collegiate Programming Contest的更多相关文章
- ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syria, Lattakia, Tishreen University, April, 30, 2018
ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syr ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)
Floor Function Time Limit: 10 Seconds Memory Limit: 65536 KB a, b, c and d are all positive int ...
- 模拟赛小结:2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017)
比赛链接:传送门 本场我们队过的题感觉算法都挺简单的,不知道为啥做的时候感觉没有很顺利. 封榜后7题,罚时1015.第一次模拟赛金,虽然是北欧的区域赛,但还是有点开心的. Problem B Best ...
- The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540
Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Othe ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...
随机推荐
- 洛谷P3292 [SCOI2016]幸运数字 线性基+倍增
P3292 [SCOI2016]幸运数字 传送门 题目描述 A 国共有 n 座城市,这些城市由 n-1 条道路相连,使得任意两座城市可以互达,且路径唯一.每座城市都有一个幸运数字,以纪念碑的形式矗立在 ...
- 【转】Java面试题:多继承
招聘和面试对开发经理来说是一个无尽头的工作,虽然有时你可以从HR这边获得一些帮助,但是最后还是得由你来拍板,或者就像另一篇文章“Java 面试题:写一个字符串的反转”所说: 面试开发人员不仅辛苦而且乏 ...
- must appear in the GROUP BY clause or be used in an aggregate function
今天在分组统计的时候pgsql报错 must appear in the GROUP BY clause or be used in an aggregate function,在mysql里面是可以 ...
- redis最新版本安装及开机自启
的系统是ubuntu,安装方式有多种,一种是通过apt仓库,一种是下载源码,编译安装 1.通过apt仓库 具体命令: sudo apt-get update sudo apt-get install ...
- Some collections were archived because you’ve reached the shared requests limits.错误解决
今天打开我的postman 发现我的一个collection不见了,左下角出现一个提示, Some collections were archived because you’ve reached t ...
- Go 每日一库之 go-ini
简介 ini 是 Windows 上常用的配置文件格式.MySQL 的 Windows 版就是使用 ini 格式存储配置的. go-ini是 Go 语言中用于操作 ini 文件的第三方库. 本文介绍g ...
- .Net Core 导出Html到PDF
前言 最近由于项目的需求问题,涉及到了在.Net Core中导出PDF的一个问题,最后选择方式是后端拼接到Html页面然后再通过Html导出到PDF.中间也尝试了许多的NuGet包.但是并不如意,可用 ...
- HTML中使用Vue+Dhtmlxgantt制作任务进度图
HTML中使用Vue+Dhtmlxgantt制作任务进度图 Dhtmlxgantt官网: https://dhtmlx.com/docs/products/dhtmlxGantt/ 参考文章 甘特图配 ...
- 单调队列优化 dp
The only difference between easy and hard versions is the constraints. Vova likes pictures with kitt ...
- dp-划分数 (递推)
问题描述 : 有 n 个无区别的物品 , 将他们分成 不超过 m 堆, 问有多少种分法 ? 例如 : n = 4 , m = 3 , 则总共有的分法是 1 + 2 +1 , 0 + 1 + 3 , 0 ...