6342.Problem K. Expression in Memories

这个题就是把?变成其他的使得多项式成立并且没有前导零

官方题解:

没意思,好想咸鱼,直接贴一篇别人的博客,写的很好,比我的垃圾好多了。。。

HDU 6342(模拟)

贴一下一个队友的代码:

 //1011-6342-模拟
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll; const double PI=acos(-1.0);
const double eps=1e-;
const ll mod=1e9+;
const int inf=0x3f3f3f3f;
const int maxn=1e5+;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int a[maxn];
char c[maxn]; int main()
{
int t;
scanf("%d",&t);
while(t--){
int flag=;
scanf("%s",c+);
int n=strlen(c+);
for(int i=;i<=n;i++){
if(c[i]>=''&&c[i]<='')
a[i]=;
else if(c[i]=='?')
a[i]=;
else
a[i]=;
if(i!=){
if(a[i]==&&a[i-]==){//++
flag=;
break;
}
}
}
if(c[]==''&&a[]==&&n>){//
if(c[]=='?'){
if(n>&&a[]==)
c[]='+',a[]=;
else
flag=;
}
else
flag=;
}
if(a[n]==||a[]==)//1+ +1
flag=;
for(int i=;i<=n;i++){
if(a[i-]==&&c[i]==''&&a[i+]==&&i>&&i<n){
if(c[i+]!='?'){//
flag=;
break;
}
else if(c[i+]=='?'&&i+>=n){//0?
flag=;
break;
}
}
if(a[i-]==&&c[i]==''&&c[i+]=='?'&&i>&&i+<n){
if(a[i+]==){//0?0
c[i+]='+';
a[i+]=;
}
else{//0?+
flag=;
break;
}
}
}
if(flag)
printf("IMPOSSIBLE\n");
else{
for(int i=;i<=n;i++){
if(c[i]=='?')
c[i]='';
printf("%c",c[i]);
}
cout<<endl;
}
}
}

我发现我的模拟题都写得相当垃圾。。。

垃圾滚了。。。

HDU 6342.Problem K. Expression in Memories-模拟-巴科斯范式填充 (2018 Multi-University Training Contest 4 1011)的更多相关文章

  1. 2018 Multi-University Training Contest 4 Problem K. Expression in Memories 【模拟】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6342 Problem K. Expression in Memories Time Limit: 200 ...

  2. 杭电多校第四场 Problem K. Expression in Memories 思维模拟

    Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262 ...

  3. HDU6342-2018ACM暑假多校联合训练4-1011-Problem K. Expression in Memories

    Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262 ...

  4. @hdu - 6329@ Problem K. Transport Construction

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定 n 个点,第 i 个点位于 (xi, yi). 在第 i ...

  5. hdu 3038 How Many Answers Are Wrong(种类并查集)2009 Multi-University Training Contest 13

    了解了种类并查集,同时还知道了一个小技巧,这道题就比较容易了. 其实这是我碰到的第一道种类并查集,实在不会,只好看着别人的代码写.最后半懂不懂的写完了.然后又和别人的代码进行比较,还是不懂,但还是交了 ...

  6. 2015 Multi-University Training Contest 8 hdu 5390 tree

    tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 5390 ...

  7. 2015 Multi-University Training Contest 7 hdu 5379 Mahjong tree

    Mahjong tree Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  8. Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem K. UTF-8 Decoder 模拟题

    Problem K. UTF-8 Decoder 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c702 ...

  9. 2017 Multi-University Training Contest - Team 9 1004&&HDU 6164 Dying Light【数学+模拟】

    Dying Light Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tot ...

随机推荐

  1. BZOJ4513 SDOI2016储能表(数位dp)

    如果n.m.k都是2的幂次方,答案非常好统计.于是容易想到数位dp,考虑每一位是否卡限制即可,即设f[i][0/1][0/1][0/1]为第i位是/否卡n.m.k的限制时,之前的位的总贡献:g[i][ ...

  2. 【题解】POI2014FAR-FarmCraft

    这题首先手玩一下一下数据,写出每个节点修建软件所需要的时间和到达它的时间戳(第一次到达它的时间),不难发现实际上就是要最小化这两者之和.然后就想到:一棵子树内,时间戳必然是连续的一段区间,而如果将访问 ...

  3. HDU.2095(异或运算)

    find your present (2) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...

  4. taotao用户登录(及登录成功后的回调url处理)

    后台Controller: package com.taotao.sso.controller; import org.springframework.stereotype.Controller; i ...

  5. Codeforces Round #525 (Div. 2)B. Ehab and subtraction

    B. Ehab and subtraction 题目链接:https://codeforc.es/contest/1088/problem/B 题意: 给出n个数,给出k次操作,然后每次操作把所有数减 ...

  6. 类名.class 类名.this 详解

    我们知道在java中,一个类在被加载的时候虚拟机就会自动的生成一个这个类的一个Class类型的“类对象”,每个类都对应着一个这样的类对象,通过这个Class类型的类对象,我们就能够使用“内省与反射”机 ...

  7. apply()和call()

    每个函数都包含俩个非继承而来的方法:apply() 和 call(),这俩个方法的用途都是在特定的作用域中调用函数,实际上等于设置函数体内this对象的值,以扩充函数赖以运行的作用域.一般来讲,thi ...

  8. 网络(bzoj 4538)

    Description 一个简单的网络系统可以被描述成一棵无根树.每个节点为一个服务器.连接服务器与服务器的数据线则看做一条树边.两个服务器进行数据的交互时,数据会经过连接这两个服务器的路径上的所有服 ...

  9. HDU5748---(记录每个元素的 最长上升子序列 nlogn)

    分析: 给一个序列,求出每个位置结尾的最长上升子序列 O(n^2) 超时 #include "cstdio" #include "algorithm" #def ...

  10. Drupal7所见即所得模块CKEditor

    初学Drupal(7.26),刚好遇到一个需要用到CKEditor模块的项目,于是就摸索着把它给装上了. 图片上传出问题 回到Drupal7的管理页面后刚好发现了对于CKEditor的“状态报告”(错 ...