A - Relic Discovery

签到

#include <cstdio>
using namespace std;
int T,n;
long long ans=0;
int main()
{
scanf("%d",&T);
for(int t=1; t<=T; t++)
{
scanf("%d",&n);
ans=0;
for(int i=1; i<=n; i++)
{
int a,b;
scanf("%d%d",&a,&b);
ans+=a*b;
}
printf("%lld\n",ans);
}
return 0;
}

  

B - Pocket Cube

直接模拟六种转法。

#include <cstdio>

using namespace std;
int T,n;
long long ans=0;
int st[200];
int t[200]; int check()
{
for (int j = 1; j <= 24; j += 4)
{
int i = j+'a'-1;
if (t[i] != t[i+1] || t[i+1] != t[i+2] || t[i+2] != t[i+3]) return 0;
}
return 1;
} int mov(char a, char b, char c, char d, char e, char f, char g, char h)
{
int k;
for (int i = 1; i <= 24; i++) t[i+'a'-1] = st[i+'a'-1]; for (int i = 1; i <= 2; i++)
k = t[a], t[a] = t[b], t[b] = t[c], t[c] = t[d], t[d] = t[e], t[e] = t[f], t[f] = t[g], t[g] = t[h], t[h] = k;
if (check()) return 1; for (int i = 1; i <= 24; i++) t[i+'a'-1] = st[i+'a'-1];
for (int i = 1; i <= 2; i++)
k = t[h], t[h] = t[g], t[g] = t[f], t[f] = t[e], t[e] = t[d], t[d] = t[c], t[c] = t[b], t[b] = t[a], t[a] = k;
if (check()) return 1;
return 0;
} int main()
{
int T;
scanf("%d", &T);
for (int ca = 1; ca <= T; ca++)
{
for (int i = 1; i <= 24; i++) scanf("%d", &st[i+'a'-1]);
int flag = 0; for (int i = 1; i <= 24; i++)
t[i+'a'-1] = st[i+'a'-1];
if (check()) flag = 1;
if (mov('a','c','e','g','i','k','m','o')) flag = 1;
if (mov('q','s','g','h','x','v','n','m')) flag = 1;
if (mov('q','r','a','b','u','v','l','k')) flag = 1;
if (flag) printf("YES\n");
else printf("NO\n");
}
return 0;
}

  

C - Pocky

记住ln(2)=0.693147。故ans = ln(L) / ln(d)。

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std; int main()
{
int t;
scanf("%d", &t);
for (int ca = 1; ca <= t; ca++)
{
double l, d;
scanf("%lf%lf", &l, &d);
if (l <= d) printf("0.000000\n");
else printf("%.6f\n", 1+log(l/d));
}
}

  

D - Lucky Coins

E - Fibonacci

F - Lambda Calculus

G - Coding Contest

H - Pattern

I - Travel Brochure

J - Cliques

K - Finding Hotels

K-d树。题目数据有问题,爆搜也能过。下面的AC代码连样例都过不了。。这数据水的一批。

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdlib> using namespace std;
const int MAXN=2e5+100;
const int DIM=10;
inline double sqr(double x){
return x*x;
}
namespace KDTree{
int K;
struct Point{
int x[DIM];
int price, id;
double distance(const Point& b)const{
double ret=0;
for(int i=0;i<K;i++){
ret+=sqr(x[i]-b.x[i]);
}
return ret;
}
void input(int lll){
id = lll;
for(int i=0;i<K;i++)scanf("%d",&x[i]);
scanf("%d", &price);
}
void output(){
printf("%d %d %d\n",x[0], x[1], price);
}
};
struct qnode{
Point p;
double dis;
qnode(){}
qnode(Point _p,double _dis){
p=_p;dis=_dis;
}
bool operator<(const qnode &b)const{
if (fabs(dis-b.dis) < 0.00001) return p.id < b.p.id;
return dis<b.dis;
}
};
priority_queue<qnode>q;
struct cmpx{
int div;
cmpx(const int &_div){
div=_div;
}
bool operator()(const Point &a,const Point &b){
for(int i=0;i<K;i++){
if(a.x[(div+i)%K]!=b.x[(div+i)%K]){
if (a.x[(div+i)%K] !=b.x[(div+i)%K]) return a.x[(div+i)%K]<b.x[(div+i)%K];
return a.id<b.id;
}
}
return true;
}
};
bool cmp(const Point &a,const Point &b,int div){
cmpx cp=cmpx(div);
return cp(a,b);
}
struct Node{
Point e;
Node *lc,*rc;
int div;
}pool[MAXN],*tail,*root;
void init(){
tail=pool;
}
Node *build(Point *a,int l,int r,int div){
if(l>=r)return NULL;
Node *p=tail++;
p->div=div;
int mid=(l+r)/2;
nth_element(a+l,a+mid,a+r,cmpx(div));
p->e=a[mid];
p->lc=build(a,l,mid,(div+1)%K);
p->rc=build(a,mid+1,r,(div+1)%K);
return p;
}
void search(Point p,Node *x,int div,int m){
if(!x)return;
if(cmp(p,x->e,div)){
search(p,x->lc,(div+1)%K,m);
if(q.size()<m){
if (x->e.price <= p.price)
q.push(qnode(x->e,p.distance(x->e)));
search(p,x->rc,(div+1)%K,m);
}else{
if(p.distance(x->e)<q.top().dis){
if (x->e.price <= p.price)
q.pop(), q.push(qnode(x->e,p.distance(x->e)));
}
if(sqr(x->e.x[div]-p.x[div])<q.top().dis){
search(p,x->rc,(div+1)%K,m);
}
}
}else{
search(p,x->rc,(div+1)%K,m);
if(q.size()<m){
if (x->e.price <= p.price) q.push(qnode(x->e,p.distance(x->e)));
search(p,x->lc,(div+1)%K,m);
}else{
if(p.distance(x->e)<q.top().dis){
if (x->e.price <= p.price)
q.pop(), q.push(qnode(x->e,p.distance(x->e)));
}
if(sqr(x->e.x[div]-p.x[div])<q.top().dis)
search(p,x->lc,(div+1)%K,m);
}
}
}
void search(Point p,int m){
while(!q.empty())q.pop();
search(p,root,0,m);
}
};
KDTree::Point p[MAXN];
int main(){
int t;
scanf("%d", &t);
for (int ca = 1; ca<=t; ca++)
{
int n, Q;
scanf("%d%d",&n, &Q);
KDTree::K=2;
for(int i=0;i<n;i++)p[i].input(i);
KDTree::init();
KDTree::root=KDTree::build(p,0,n,0); KDTree ::Point o;
while(Q--){
o.input(1000000);
int m;
//scanf("%d",&m);
m = 1;
KDTree::search(o,1);
int cnt=0;
while(!KDTree::q.empty()){
p[cnt++]=KDTree::q.top().p;
KDTree::q.pop();
}
//printf(":::::");
p[0].output();
//printf("%d\n", p[0].id);
}
}
return 0;
}

  

L - Tower Attack

M - Generator and Monitor

The 2016 ACM-ICPC Asia Qingdao Regional Contest的更多相关文章

  1. 2016 ACM/ICPC Asia Regional Qingdao Online 1001/HDU5878 打表二分

    I Count Two Three Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  2. HDU 5889 Barricade 【BFS+最小割 网络流】(2016 ACM/ICPC Asia Regional Qingdao Online)

    Barricade Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  3. 2016 ACM/ICPC Asia Regional Qingdao Online(2016ACM青岛网络赛部分题解)

    2016 ACM/ICPC Asia Regional Qingdao Online(部分题解) 5878---I Count Two Three http://acm.hdu.edu.cn/show ...

  4. 2016 ACM/ICPC Asia Regional Shenyang Online 1003/HDU 5894 数学/组合数/逆元

    hannnnah_j’s Biological Test Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K ...

  5. 2016 ACM/ICPC Asia Regional Shenyang Online 1009/HDU 5900 区间dp

    QSC and Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  6. 2016 ACM/ICPC Asia Regional Shenyang Online 1007/HDU 5898 数位dp

    odd-even number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  7. 2016 ACM/ICPC Asia Regional Dalian Online 1002/HDU 5869

    Different GCD Subarray Query Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

  8. 2016 ACM/ICPC Asia Regional Dalian Online 1006 /HDU 5873

    Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  9. HDU 5874 Friends and Enemies 【构造】 (2016 ACM/ICPC Asia Regional Dalian Online)

    Friends and Enemies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  10. HDU 5875 Function 【倍增】 (2016 ACM/ICPC Asia Regional Dalian Online)

    Function Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total ...

随机推荐

  1. python类型之间的转换

    *int(x,base=10)x字符串或数字,base进制数,默认十进制 浮点转为整数 *float 整数转换为浮点型 *complex(1,2) 转换为复数 *str(10)将对象转换为字符串 *r ...

  2. iOS开发ReactiveCocoa学习笔记(二)

    RAC 中常见的宏: 使用宏定义要单独导入 #import <RACEXTScope.h> 一. RAC(TARGET, [KEYPATH, [NIL_VALUE]]):用于给某个对象的某 ...

  3. C#---vs2010发布、打包安装程序程序(转载)

    转载地址:点击打开 1. 在vs2010 选择“新建项目”→“ 其他项目类型”→“ Visual Studio Installer→“安装项目”: 命名为:Setup1 . 这是在VS2010中将有三 ...

  4. Educational Codeforces Round 51 (Rated for Div. 2)

    做了四个题.. A. Vasya And Password 直接特判即可,,为啥泥萌都说难写,,,, 这个子串实际上是忽悠人的,因为每次改一个字符就可以 我靠我居然被hack了???? %……& ...

  5. A promise tomorrow is worth a lot less than trying today.

    A promise tomorrow is worth a lot less than trying today.明日的承诺远不及今日的行动.

  6. Neo4j-3.0.3 (Debian 8)

    平台: Ubuntu 类型: 虚拟机镜像 软件包: neo4j-3.0.3 basic software database graph database infrastructure neo4j op ...

  7. Apache Solr-6.0.1 (OpenLogic CentOS 7.2)

    Apache Solr-6.0.1 (OpenLogic CentOS 7.2) 平台: CentOS 类型: 虚拟机镜像 软件包: java1.8 solr6.0.1 application ser ...

  8. WORD窗体保护密码清除

    Word 2003破解方法如下:1.用Word打开已设置有密码的“保护文档”(原始DOC文件):2.菜单中选择“文件”→“另存为Web页”,保存为HTML文件然后关闭Word:3.用文本编辑器(如:记 ...

  9. Python参数基础

    Python参数基础 位置参数 ​ 通过位置进行匹配,把参数值传递给函数头部的参数名称,顺序从左到右 关键字参数 ​ 调用的时候使用参数的变量名,采用name=value的形式 默认参数 ​ 为没有传 ...

  10. PPII打不开 更改I.bat

    http://jingyan.baidu.com/article/3a2f7c2e7d277126afd6118d.html