题目链接:https://codeforces.ml/gym/102428/attachments/download/9820/statements-en.pdf

题意:构造一个多项式使得外星人编号的函数值小于零,人类的编号函数值大于零。

思路:零点存在问题,我们只要找出字符串中有多少A-H或者H-A的变化就是零点个数,然后利用求多项式板子的代码即可。

 1 #include<iostream>
2 #include<algorithm>
3 #include<vector>
4 #include<cstring>
5 #include<cstdio>
6 #include<bits/stdc++.h>
7 using namespace std;
8 #define mem(s,n) memset(s,n,sizeof s);
9 #define PI acos(-1.0)
10 typedef long long ll;
11 const int maxn=1e5+5;
12 const ll Inf=0x7f7f7f7f;
13 ll a[maxn],b[maxn];
14 char s[maxn];
15 int main()
16 {
17 scanf("%s",s);
18 int tot=0;
19 //cout<<strlen(s)<<endl;
20 for(int i=0;i<strlen(s)-1;i++)
21 {
22 if(s[i]==s[i+1]) continue;
23 else
24 {
25 a[++tot]=2*i+3;
26 //cout<<tot<<endl;
27 }
28 }
29 b[1]=1;
30 for(int i=1;i<=tot;i++)
31 {
32 for(int j=i+1;j>=1;j--) b[j]=b[j-1];
33 for(int j=1;j<=i+1;j++) b[j-1]-=a[i]*b[j];
34 }
35 ll k=1;
36 if(s[0]=='H'&&tot%2) k=-1;
37 if(s[0]=='A'&&tot%2==0) k=-1;
38 cout<<tot<<endl;
39 for(int i=1+tot;i>=1;i--)
40 {
41 if(i==1)
42 printf("%lld\n",b[i]*k);
43 else
44 printf("%lld ",b[i]*k);
45
46 }
47 return 0;
48 }

(训练的时候真是菜,一个很小的问题错了w了五次真白给)

International Collegiate Programming Contest 2019 Latin American Regional Contests Problem K的更多相关文章

  1. ACM International Collegiate Programming Contest World Finals 2014

    ACM International Collegiate Programming Contest World Finals 2014 A - Baggage 题目描述:有\(2n\)个字符摆在编号为\ ...

  2. ACM International Collegiate Programming Contest World Finals 2013

    ACM International Collegiate Programming Contest World Finals 2013 A - Self-Assembly 题目描述:给出\(n\)个正方 ...

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

  4. ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2017)- K. Poor Ramzi -dp+记忆化搜索

    ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2017)- K. ...

  5. 2019.04.04 第二次训练 【ACM International Collegiate Programming Contest, JUST Collegiate Programming Contest (2018)】

    题目链接:https://codeforces.com/gym/101853 A: ✅ B: (二分图匹配) https://blog.csdn.net/qq_41997978/article/det ...

  6. ICPC — International Collegiate Programming Contest Asia Regional Contest, Yokohama, 2018–12–09 题解

    目录 注意!!此题解存在大量假算法,请各位巨佬明辨! Problem A Digits Are Not Just Characters 题面 题意 思路 代码 Problem B Arithmetic ...

  7. Gym100814B Gym100814F Gym100814I(异或) ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest (2015) Arab Academy for Science and Technology

    今日份的训练题解,今天写出来的题没有昨天多,可能是因为有些事吧... Gym100814B 这个题就是老师改卷子,忘带标准答案了,但是他改了一部分卷子,并且确定自己改的卷子没出错,他想从改过的卷子里把 ...

  8. [ACM International Collegiate Programming Contest, Amman Collegiate Programming Contest (2018)]

    https://codeforces.com/gym/101810 A. Careful Thief time limit per test 2.5 s memory limit per test 2 ...

  9. ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest (ECPC 2015)

    A.Arcade Game(康拓展开) 题意: 给出一个每个数位都不同的数n,进行一场游戏.每次游戏将n个数的每个数位重组.如果重组后的数比原来的数大则继续游戏,否则算输.如果重组后的数是最大的数则算 ...

随机推荐

  1. spring-cloud-netflix-eureka-client

    服务注册中心eureka-server已经搭好,我们开始编写一个eureka-client,并提供一个hello服务 一.新建module,选择对应的springcloud模块,pom.xml如下: ...

  2. C++ STL (基础)

    STL是什么(STL简介) 本节主要讲述 STL 历史.STL 组件.STL 基本结构以及 STL 编程概述.STL 历史可以追溯到 1972 年 C 语言在 UNIX 计算机上的首次使用.直到 19 ...

  3. P3373 线段树2(多重标记线段树)题解

    题意: 操作有:区间加,区间乘,区间询问求和 思路: 设一个数为\(m*sum+a\),加就变成了\(m*sum+a+a_2\),乘就变成了\(m*m_2*sum+a*m_2\),所以我们设两个标记\ ...

  4. Gym 101480I Ice Igloos(思维乱搞)题解

    题意:给个最多500 * 500的平面,有半径最多不为1的n个圆,现在给你1e5条线段,问你每条线段和几个圆相交,时限10s 思路: 因为半径<1,那么我其实搜索的范围只要在线段附近就好了.x1 ...

  5. HTTP/HTTPS Proxy & Charles

    HTTP/HTTPS Proxy & Charles Charles https://www.charlesproxy.com/ https://www.jianshu.com/p/53d2c ...

  6. Flutter & App

    Flutter & App Android & iOS https://flutter.dev/docs/deployment/flavors https://flutter.dev/ ...

  7. flutter & plugins

    flutter & plugins https://pub.dev/ https://juejin.im/post/5c206b4ff265da61327f52f4

  8. Flutter 模拟youtube快进icon

    import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends State ...

  9. PAA房产,一家有温度的房产公司

    PAUL ADAMS ARCHITECT房产(以下简称PAA,公司编号:07635831)对每一个客户从心出,为他们选择优质房源,为他们缔造家的温暖.PAA房产,是一家有温度的房产公司. PAA房产( ...

  10. K8S线上集群排查,实测排查Node节点NotReady异常状态

    一,文章简述 大家好,本篇是个人的第 2 篇文章.是关于在之前项目中,k8s 线上集群中 Node 节点状态变成 NotReady 状态,导致整个 Node 节点中容器停止服务后的问题排查. 文章中所 ...