训练实录 | 第 45 届ICPC沈阳站(牛客重现赛)

本文记录了第45届ICPC亚洲区域赛(沈阳)重现赛的参赛经历,重点解析了题目F - The Witchwood和I - Rise of Shadows。在F题中,讨论了区间和的处理方法;在I题中,通过转化问题,应用同余定理和反证法解决了夹角计数问题,得出解的数量为g(2*gA+1),其中g为最大公约数。
摘要由CSDN通过智能技术生成

第 45 届国际大学生程序设计竞赛(ICPC)亚洲区域赛(沈阳)(重现赛)

传送门:ICPC沈阳

F - The Witchwood

这重现赛,这数据,我既然被hack了,我写的代码太拉跨了?????
对原来的代码做了亿点点修改:对于每一个小区间,区间内的和与排序后区间内的和是一样的。所以。。。。

#pragma warning(disable:4996)
#include<iostream>
#include<string.h>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<set>
#include<algorithm>
#include<sstream>
#include<vector>
#include<ctype.h>
#include<list>
//#include <unordered_map>
#include<deque>
#include<functional>
using namespace std;

const int maxn = 1e6 + 9;
long long a[maxn], sorted[maxn], le = 0, ri = 0, minn = 0x3f3f3f3f, maxx = 0;

int main()
{
   
    int n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
   
        cin >> a[i];
        sorted[i] = a[i];
    }
    long long suma = 0, sumb = 0;
    sort(sorted, sorted + n);
    for (int i = 0; i < n; i++) {
   
        suma += a[i];
        sumb += sorted[i];
        if (suma == sumb)ans++;
    }
    cout << ans;
    return 0;
}

G - The Witchwood

solved by Micky. 00:32:02(+)

签到。略

#pragma warning(disable:4996)
#include<iostream>
#include<string.h>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<set>
#include<algorithm>
#include<sstream>
#include<vector>
#include<ctype.h>
#include<list>
//#include <unordered_map>
#include<deque>
#include<functional>
using namespace std;

const int maxn = 1e5 + 9;
long long a[maxn], ans, n, k;

int main()
{
   
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
   
        cin >> a[i];
    }
    sort(a, a + n);
    for (int i = n - 1; i >= n - k; i--) {
   
        ans += a[i];
    }
    cout << ans;
    return 0;
}

I - Rise of Shadows

solved by oye (after).

题意:
给你一个特定的钟,有H小时,每小时有M分钟。问从0:00开始,时钟转完一圈的时间内,分钟和时钟的夹角小于等于 2 π A H M \frac{2\pi A}{HM} HM2πA的次数有几次(分针指到格子线才算一次)
一开始,我和我的队友都以为是追及问题,怎么都过不了,一直卡到赛后。也不明白为什么是奇数,后来才发现,最后的那个重合是不用算的,相当于我们现实生活中,实际有效时间其实只有0:00~11:59(我指转一圈)。
因为要分针指到格子线才算一次,追及算时间算路程那个没法用,所以用假设先把题目化成通式。

假设一时间为 t ( t ∈ [ 0 , H M ) , t ∈ Z , 单 位 : 分 钟 ) t(t\in[0,HM),t\in Z,单位:分钟) t(t[0,HM)tZ,</

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值