gym101522 [小熊骑士限定]La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017
西瓜队(划掉),Kuma Rider久违的第一场训练,四小时瞎打.jpg
A.水题,排序
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
#define lowbit(i) ((i)&(-i))
const ll maxv = 1e5 + ; ll n,d[maxv], c[maxv]; void update(ll x, ll v)
{
for (ll i = x; i < maxv; i+=lowbit(i))
{
c[i] += v;
}
} ll getsum(ll x)
{
ll sum = ;
for (ll i = x; i > ; i -= lowbit(i))
{
sum += c[i];
}
return sum;
} int main()
{
scanf("%lld", &n);
for (ll i = ; i <= n; i++)
{
scanf("%lld", &d[i]);
}
sort(d+ , d+ + n);
ll ans = ;
for (ll i = ; i <= n; i++)
{
ll num = getsum(i-);
num = (i - ) - num;
//printf("%lld %lld\n", i, num);
ans += num;
update(d[i], );
}
ans *= ;
printf("%lld\n", ans);
}
B.找到树的直径,倍增地跳跃计算答案
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<functional>
#include<vector>
using namespace std;
typedef long long LL; int n;
vector<int>e[];
bool vis[];
int Root, Tail; int BFS(int st)
{
for (int i = ; i <= n; i++)vis[i] = false;
queue<int>q;
q.push(st);
vis[st] = true;
int ret = st;
while (!q.empty())
{
int t = q.front(); q.pop();
ret = t;
for (int i = ; i < e[t].size(); i++)
{
int to = e[t][i];
if (!vis[to])
{
q.push(to);
vis[to] = true;
}
}
}
return ret;
} int len; void DFS(int nx, int pr, int st)
{
len = max(len, st);
for (int i = ; i < e[nx].size(); i++)
{
int to = e[nx][i];
if (to != pr)
{
DFS(to, nx, st + );
}
}
} int main()
{
scanf("%d", &n);
for (int i = ; i <= n - ; i++)
{
int u, v;
scanf("%d %d", &u, &v);
e[u].push_back(v);
e[v].push_back(u);
}
Root = BFS();
Tail = BFS(Root);
len = ;
DFS(Root, -, );
//printf("%d %d\n", Root, Tail);
int ans = ;
int tl = ;
while (tl<len-)
{
ans++;
tl <<= ;
}
printf("%d\n", ans); }
C.水题
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<string>
#include<vector>
#include<map>
using namespace std; char s[];
int main()
{
scanf("%s", s);
int len = strlen(s);
int lsc = , pcms = ;
for (int i = ; i < len-; i++)
{
if (s[i] == 'L'&&s[i + ] == 'S'&&s[i + ] == 'C')lsc++;
}
for (int i = ; i < len - ; i++)
{
if (s[i] == 'P'&&s[i + ] == 'C'&&s[i + ] == 'M'&&s[i + ] == 'S')pcms++;
}
if (pcms > lsc)printf("PCMS\n");
else if (pcms < lsc)printf("LSC\n");
else printf("Tie\n"); }
D.比赛没来得及写的题。(1953.1.1居然是星期六!!一直以为是星期日!!!)
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#include<map>
#include<vector>
#include<set>
#include<queue>
using namespace std;
int days[] = { , , , , , , , , , , , , }; int q, st, ed, day, month, gi[], ans[]; bool isleap(int year)
{
return (year % == ) || ((year % == ) && (year % ));
} int cal(int yy, int mm, int dd)
{
int sum = ;
for (int i = ; i < mm; i++)
{
sum += days[i];
if (isleap(yy) && i == )
sum++;
}
return sum+dd-;
} void cycle(int mm,int dd)
{
int cnt=,now = ;//1953/1/1是星期六
for (int i = ; i <= + ; i++)
{
if (mm == && dd == && !isleap(i))
{
ans[cnt++] = ;
}
else
{
ans[cnt++] = (cal(i, mm, dd) + now - ) % + ;
}
if (isleap(i))
now = (now + - ) % + ;
else
now = (now + - ) % + ;
}
} int main()
{
scanf("%d", &q);
while (q--)
{
memset(ans, , sizeof(ans));
memset(gi, , sizeof(gi));
scanf("%d %d %d %d", &st, &ed, &month, &day);
cycle(month, day);
int numed = (ed- + ) / ;
int numst = (st - ) / ;
for (int i = ; i <= ; i++)
{
gi[ans[i]] += (numed - numst);
}
int mped = ed - + - numed * ;
int mpst = st - - numst * ;
for (int i = ; i <= mpst; i++)
{
gi[ans[i]]--;
}
for (int i = ; i <= mped; i++)
{
gi[ans[i]]++;
}
printf("%d", gi[]);
for (int i = ; i <= ; i++)
{
printf(" %d", gi[i]);
}
puts("");
}
return ;
}
E.还没看,待补
F.还没写,待补
G.还没写,待补
H.几何板子题,两圆交点,我抄错板子错了好久quq
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<functional>
#include<vector>
using namespace std;
const double eps = 1e-; struct Point
{
double x, y;
Point(double _a, double _b) :x(_a), y(_b) {}
Point() {}
}; Point intersection(const Point &u1, const Point &u2, const Point &v1, const Point &v2)
{
Point res = u1;
double t = ((u1.x - v1.x)*(v1.y - v2.y) - (u1.y - v1.y)*(v1.x - v2.x)) / ((u1.x - u2.x)*(v1.y - v2.y) - (u1.y - u2.y)*(v1.x - v2.x));
res.x += (u2.x - u1.x)*t;
res.y += (u2.y - u1.y)*t;
return res;
} double dis(const Point &p1, const Point &p2)
{
return sqrt((p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y));
} void play(const Point &c, double r, const Point &l1, const Point &l2, Point &p1, Point &p2)
{
Point p = c;
p.x += l1.y - l2.y;
p.y += l2.x - l1.x;
p = intersection(p, c, l1, l2);
double t = sqrt(r*r - dis(p, c)*dis(p, c)) / dis(l1, l2);
p1.x = p.x + (l2.x - l1.x)*t;
p1.y = p.y + (l2.y - l1.y)*t;
p2.x = p.x - (l2.x - l1.x)*t;
p2.y = p.y - (l2.y - l1.y)*t;
} void play2(const Point &c1, double r1, const Point &c2, double r2, Point &p1, Point &p2)
{
Point u, v;
double t = ( + (r1*r1 - r2*r2) / dis(c1, c2) / dis(c1, c2)) / ;
u.x = c1.x + (c2.x - c1.x)*t;
u.y = c1.y + (c2.y - c1.y)*t;
v.x = u.x + c1.y - c2.y;
v.y = u.y - c1.x + c2.x;
play(c1, r1, u, v, p1, p2);
} double x1, x2, r1, yy, y2, r2; int main()
{
cin >> x1 >> yy >> r1;
cin >> x2 >> y2 >> r2;
Point ans1, ans2;
if (r1 > r2) {
swap(x1, x2);
swap(yy, y2);
swap(r1, r2);
}
double ds = dis(Point(x1, yy), Point(x2, y2));
if (r2 >= ds)
{
printf("%.6lf %.6lf\n", x1, yy);
return ;
}
play2(Point(x1, yy), r1, Point(x2, y2), r2, ans1, ans2);
printf("%.6lf %.6lf\n", ans1.x, ans1.y);
return ;
}
I.瞎搞
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
const double eps = 1e-;
ll ax[];
int main(void) {
ll n;
scanf("%lld", &n);
for (int i = ; i < n; i++) {
scanf("%lld", &ax[i]);
}
if (n == ) {
printf("0\n");
return ;
}
else if (n == ) {
printf("%lld\n", min(abs(ax[] - ax[]),abs(ax[]+ax[])));
return ;
}
vector<ll>v;
ll sum = ;
for (int i = ; i<n - ; i++) {
sum += abs(ax[i + ] - ax[i]);
v.push_back(abs(ax[i + ] + ax[i]) - abs(ax[i + ] - ax[i]));
}
sort(v.begin(), v.end());
if (v[] < ) {
sum += v[];
}
if (v[] < ) {
sum += v[];
}
printf("%lld\n", sum);
}
J.还没写,待补
K.水题,四个角满足即可
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<functional>
#include<vector>
using namespace std;
typedef long long LL; int n; int main()
{
int n, m, k;
int cnt = ;
scanf("%d %d %d", &n, &m, &k);
for (int i = ; i <= k; i++)
{
int x, y;
scanf("%d %d", &x, &y);
if (x == && y == m)
cnt++;
else if (x == && y == )
cnt++;
else if (x == n&&y == )
cnt++;
else if (x == n&&y == m)
cnt++;
}
int tmp = ;
if (n == && m == )
tmp = ;
else if (n == || m == )
tmp = ;
printf("%d\n", tmp - cnt);
return ;
}
L.还没写,待补
gym101522 [小熊骑士限定]La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017的更多相关文章
- Codeforces Gym101522 C.Cheering-字符串 (La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017)
C.Cheering To boost contestants' performances in the 20th La Salle - Pui Ching Programming Challenge ...
- Codeforces Gym101522 D.Distribution of Days-算日期 (La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017)
D.Distribution of Days The Gregorian calendar is internationally the most widely used civil calendar ...
- Codeforces Gym101522 A. Ambiguous Dates (La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017)
A. Ambiguous Dates There are two popular formats for representing a date: day/month/year or month/da ...
- gym100676 [小熊骑士限定]2015 ACM Arabella Collegiate Programming Contest
Kuma Rider久违的第二场训练,这场很水,又在vj的榜单上看到第一场的大哥了,2小时ak,大哥牛啤! A.水 #include<cstdio> #include<iostrea ...
- 动词的时态(Les temps du verbe )
在开始讲解直陈式现在时的主要用法之前,我们有必要先搞清楚两个基本概念:▶语式(mode):语式是动词表达动作的方式.一个动作,可以作为实在的事表达出来,也可以作为希望或单纯设想的事表达出来,法语动词共 ...
- 每周一书-《鸟哥的Linux私房菜》获奖公布
<鸟哥的Linux私房菜>一书的赠书活动时间为2016年10月19日到10月31日, 也就是今天结束. 首先要感谢QQ号为:1084830483(路在远方),来自哈尔滨工程大学的同学赠送给 ...
- 2017年USNews美国大学研究生专业排名
2017年USNEWS美国大学研究生专业排名最佳商学院排名 排名 学校 费用 注册人数 #1 Harvard University Boston, MA $61,225 per year (full- ...
- CVPR 2017 Paper list
CVPR2017 paper list Machine Learning 1 Spotlight 1-1A Exclusivity-Consistency Regularized Multi-View ...
- 数据库 之MySQL 简单教程
So Easy系列之MySQL数据库教程 1. 数据库概述 1.1. 数据库概述 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库,它产生于距今六十多年前,随着信息技术和 ...
随机推荐
- 解决web网站被挂马清除方法
案例:某公司一个lamp的服务器网站站点目录下所有文件均被植入了广告脚本如下内容: <script language=javascriptsrc=http://%4%66E%78%72%67%2 ...
- python 计时器
今天做自动化界面工具的时候需要用到计时器,查阅了一下,发现以下的这位博友写的很简洁方便且实用 https://blog.csdn.net/qfxx_CSDN/article/details/81412 ...
- 小渣渣的json和jsonp和ajax的实质和区别
json和jsonp和ajax的实质和区别ajax的两个问题 1.ajax以何种格式来交换数据 2.跨域的需求如何解决 数据跨域用自定义字符串或者用XML来描述 跨域可以用服务器代理来解决jsonp来 ...
- 【js】实现继承的6种方法
1.原型链 基本思想:利用原型链让一个引用类型继承另一个引用类型的属性和方法. 让原型对象(B.prototype)等于另一个类型的实例(new A()), 即B.prototype = new A( ...
- MySQL keepalived 双主.md
MySQL keepalived 双主搭建 环境说明 系统 IP 主机名 mysql keepalived VIP CentOS 6.8 192.168.197.61 C6-node1 5.6.36 ...
- windows下mysql和linux下mysql主从配置
1. linux下mysql安装版本5.6 windows下mysql版本5.7 不要问我为什么版本不一致 就是想这么搞 2. linux为主服务器 windows为从服务器 3.找到li ...
- 同一域环境下SQLServer DB Failover故障转移配置详解
前 言: 很多情况下,虽然我们的站点.APIService.Redis等已经做成了分布式架构,但是SQLServer依然还是单体结构,当出现网络异常.服务器宕机时便存在极大的风险,这时候我们需要 ...
- Arthas开源项目
本文主要围绕着Arthas是什么.能做什么.安装和使用等三个方面内容来讲解,希望对初学者和对此有兴趣的朋友有帮助. 一. Arthas是什么 文档地址: https://alibaba.github. ...
- 关于javascript中对浮点加,减,乘,除的精度分析
大学专业是计算机童鞋或多或小的知道 计算机是由二进制存储和处理数字的,不能精确到处理浮点数,且javascript也没有这样的方法 所以在浏览器计算的时候也会有误差,比如说 我想用 3.3 / 1.1 ...
- JAVA框架 Spring 和Mybatis整合(传统dao)
一:我们使用spring处理service,mybaits处理dao层. 二:导入jar包 pom.xml文件内容: <?xml version="1.0" encoding ...