西瓜队(划掉),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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. gym100676 [小熊骑士限定]2015 ACM Arabella Collegiate Programming Contest

    Kuma Rider久违的第二场训练,这场很水,又在vj的榜单上看到第一场的大哥了,2小时ak,大哥牛啤! A.水 #include<cstdio> #include<iostrea ...

  5. 动词的时态(Les temps du verbe )

    在开始讲解直陈式现在时的主要用法之前,我们有必要先搞清楚两个基本概念:▶语式(mode):语式是动词表达动作的方式.一个动作,可以作为实在的事表达出来,也可以作为希望或单纯设想的事表达出来,法语动词共 ...

  6. 每周一书-《鸟哥的Linux私房菜》获奖公布

    <鸟哥的Linux私房菜>一书的赠书活动时间为2016年10月19日到10月31日, 也就是今天结束. 首先要感谢QQ号为:1084830483(路在远方),来自哈尔滨工程大学的同学赠送给 ...

  7. 2017年USNews美国大学研究生专业排名

    2017年USNEWS美国大学研究生专业排名最佳商学院排名 排名 学校 费用 注册人数 #1 Harvard University Boston, MA $61,225 per year (full- ...

  8. CVPR 2017 Paper list

    CVPR2017 paper list Machine Learning 1 Spotlight 1-1A Exclusivity-Consistency Regularized Multi-View ...

  9. 数据库 之MySQL 简单教程

      So Easy系列之MySQL数据库教程 1.   数据库概述 1.1.  数据库概述 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库,它产生于距今六十多年前,随着信息技术和 ...

随机推荐

  1. Coursera-AndrewNg(吴恩达)机器学习笔记——第四周

    神经网络 1.神经网络发展的动力:在逻辑回归解决复杂的分类问题时,我们使用属性的一些组合来构造新的属性(x12,x1x2,x22...),这样就会造成属性的数目n过多,带来了大量的运算,甚至造成过拟合 ...

  2. unbuntu 安装python包提示E: Unable to locate package python-timeout

    今天本想着在unbuntu环境下安装python的一个包,安装了几次都提示 E: Unable to locate package python-timeout 查阅了一些信息才知道,原来是一些软件源 ...

  3. November 07th, 2017 Week 45th Tuesday

    Love is composed of a single soul inhabiting two bodies. 爱就是一个灵魂栖息在两个身体里. Love and family and childr ...

  4. November 01st, 2017 Week 44th Wednesday

    People always want to lead an active life, and is not it? 人们总要乐观生活,不是吗? Be active, and walk towards ...

  5. Beta阶段第四次冲刺

    Beta阶段第四次冲刺 严格按照Git标准来,组员有上传Git的才有贡献分没有的为0 代码签入图 1.part1 -站立式会议照片 2.part2 -项目燃尽图 3.part3 -项目进展 1.正在进 ...

  6. C# MVC 使用 CKEditor图片上传 提示“不正确的服务器响应”

    重点:看一下你使用的CKEditor版本 过程: 后台需要一款富文本编辑器.经过挑选后,最后选择了FCKEditor 的升级版 CKEditor .在官网下载了4.10.1版本. 经过一番配置后,富文 ...

  7. 7.Deque的应用案例-回文检查

    - 回文检测:设计程序,检测一个字符串是否为回文. - 回文:回文是一个字符串,读取首尾相同的字符,例如,radar toot madam. - 分析:该问题的解决方案将使用 deque 来存储字符串 ...

  8. CountUp.js用法 让数字动起来的插件

    CountUp.js 无依赖的.轻量级的 JavaScript 类,可以用来快速创建以一种更有趣的动画方式显示数值数据.尽管它的名字叫 countUp,但其实可以在两个方向进行变化,这是根据你传递的 ...

  9. C++构造析构函数生命期及对象生命期

  10. 【[AHOI2013]差异】

    这个题一看就是为后缀家族设计的 我们看到我们要求的这个柿子 \[\sum_{i=1}^n\sum_{j=i+1}^nT_i+T_j-2\times lcp(T_i,T_j)\] 显然的是前面的那些东西 ...