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 ...
随机推荐
- Activity启动过程源码分析(Android 8.0)
Activity启动过程源码分析 本文来Activity的启动流程,一般我们都是通过startActivity或startActivityForResult来启动目标activity,那么我们就由此出 ...
- linux下卸载旧版本cmake安装新版本cmake
1.看当前cmake版本 cmake --version 2.卸载旧版本下的cmake apt-get autoremove cmake 3.安装新版面cmake http://www.cnblogs ...
- 转载 css截取td里面的内容 如何固定td th的宽度
源博客地址:http://blog.csdn.net/u011456552/article/details/53839255 效果图: 源码: <!DOCTYPE html> <ht ...
- ABA问题怎么解:AtomicStampedReference和AtomicMarkableReference
本博客系列是学习并发编程过程中的记录总结.由于文章比较多,写的时间也比较散,所以我整理了个目录贴(传送门),方便查阅. 并发编程系列博客传送门 并发编程的基石--CAS机制这篇文章中介绍到CAS机制有 ...
- 1z0-062 题库解析4
题目: Examine this parameter: NAME TYPE VALUE ------------------------ -- ...
- Spark集群-Standalone 模式
Spark 集群相关 table td{ width: 15% } 来源于官方, 可以理解为是官方译文, 外加一点自己的理解. 版本是2.4.4 本篇文章涉及到: 集群概述 master, worke ...
- Spring Boot 入门(十一):集成 WebSocket, 实时显示系统日志
以前面的博客为基础,最近一篇为Spring Boot 入门(十):集成Redis哨兵模式,实现Mybatis二级缓存.本篇博客主要介绍了Spring Boot集成 Web Socket进行日志的推送, ...
- JVM系列七(JIT 即时编译器).
一.概述 即时编译器(Just In Time Compiler),也称为 JIT 编译器,它的主要工作是把热点代码编译成与本地平台相关的机器码,并进行各种层次的优化,从而提高代码执行的效率. 那么什 ...
- 快速幂模板Super
//求x^nint ans=1;while(n){ if(n&1) ans=ans*x; x*=x; n>>=1;} 快速幂就是快速算底数的n次幂.其时间复杂度为 O(logN), ...
- 获取当前URL
HttpContext.Current.Request.Url.ToString();