【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

把所有的问号都改成'1'
然后会发现只有+0?这种情况
需要把?改成+.
看看这样的0后面的1是不是由问号改过来的就好了。是的话
再把这个1变成'+'就好。
判断一下首尾有符号的情况。
以及连续两个出现符号的情况。

【代码】

  1. #include <bits/stdc++.h>
  2. #define LL long long
  3. #define rep1(i,a,b) for (int i = a;i <= b;i++)
  4. #define rep2(i,a,b) for (int i = a;i >= b;i--)
  5. #define all(x) x.begin(),x.end()
  6. #define pb push_back
  7. #define lson l,mid,rt<<1
  8. #define rei(x) scanf("%d",&x)
  9. #define rel(x) scanf("%lld",&x)
  10. #define res(x) scanf("%s",x)
  11. #define rson mid+1,r,rt<<1|1
  12. using namespace std;
  13. const double pi = acos(-1);
  14. const int dx[4] = {0,0,1,-1};
  15. const int dy[4] = {1,-1,0,0};
  16. const int N = 1e5;
  17. bool flag[1000];
  18. string s;
  19. bool issign(char key){
  20. if (key=='+' || key=='*') return true;
  21. return false;
  22. }
  23. bool isnumber(char key){
  24. if (key>='0' && key<='9')
  25. return true;
  26. return false;
  27. }
  28. bool ok(){
  29. memset(flag,0,sizeof flag);
  30. int len = s.size();
  31. for (int i = 0;i < len;i++)
  32. if (s[i]=='?')
  33. flag[i] = 1;
  34. for (int i = 0;i < len;i++)
  35. if (s[i]=='?')
  36. s[i] = '1';
  37. for (int i = 0;i < len;i++){
  38. if (s[i]=='0' && (i==0 || !isnumber(s[i-1])) && i<len-1 && isnumber(s[i+1])){
  39. //s[i]是一个前导0
  40. if (!flag[i+1]) return false;
  41. s[i+1] = '+';
  42. }
  43. }
  44. if (issign(s[0]) || issign(s[len-1])) return false;
  45. for (int i = 0;i < len-1;i++)
  46. if (issign(s[i]) && issign(s[i+1]))
  47. return false;
  48. return true;
  49. }
  50. int main(){
  51. #ifdef LOCAL_DEFINE
  52. freopen("rush_in.txt", "r", stdin);
  53. //freopen("D:\\out.txt","w",stdout);
  54. #endif
  55. ios::sync_with_stdio(0),cin.tie(0);
  56. int T;
  57. cin >> T;
  58. while (T--){
  59. cin >> s;
  60. if (!ok()){
  61. cout<<"IMPOSSIBLE"<<endl;
  62. }else{
  63. cout<<s<<endl;
  64. }
  65. }
  66. return 0;
  67. }

【hdu 6342】Expression in Memories的更多相关文章

  1. 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题

    [HDU  3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...

  2. 【HDU 5647】DZY Loves Connecting(树DP)

    pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS ...

  3. -【线性基】【BZOJ 2460】【BZOJ 2115】【HDU 3949】

    [把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最 ...

  4. 【HDU 2196】 Computer(树的直径)

    [HDU 2196] Computer(树的直径) 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 这题可以用树形DP解决,自然也可以用最直观的方法解 ...

  5. 【HDU 2196】 Computer (树形DP)

    [HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题 ...

  6. 【HDU 5145】 NPY and girls(组合+莫队)

    pid=5145">[HDU 5145] NPY and girls(组合+莫队) NPY and girls Time Limit: 8000/4000 MS (Java/Other ...

  7. 【hdu 1043】Eight

    [题目链接]:http://acm.hdu.edu.cn/showproblem.php?pid=1043 [题意] 会给你很多组数据; 让你输出这组数据到目标状态的具体步骤; [题解] 从12345 ...

  8. 【HDU 3068】 最长回文

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=3068 [算法] Manacher算法求最长回文子串 [代码] #include<bits/s ...

  9. 【HDU 4699】 Editor

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=4699 [算法] 维护两个栈,一个栈放光标之前的数,另外一个放光标之后的数 在维护栈的同时求最大前缀 ...

随机推荐

  1. 卷积神经网络(CNN)基础介绍

    本文是对卷积神经网络的基础进行介绍,主要内容包含卷积神经网络概念.卷积神经网络结构.卷积神经网络求解.卷积神经网络LeNet-5结构分析.卷积神经网络注意事项. 一.卷积神经网络概念 上世纪60年代. ...

  2. 125条常见的java面试、笔试题大汇总

    1.抽象: 抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解所有问题,而仅仅是选择当中的一部分,临时不用部分细节.抽象包含两个方面,一是过程抽象. ...

  3. 开源项目 apk cfg and android app path profiling

    暑假里面完毕的一个小项目,limitation还是挺多的. 期待未来有更大的motivation 去完好它.通过此次的项目设计,对于smali的语法更加了解了,对于进一步学习android app的安 ...

  4. 简陋版:基于python的自动化测试框架开发

    项目背景: XXXX银行项目采用的是B/S架构,主要是为了解决银行业务中的柜员.凭证.现金.账务等来自存款.贷款.会计模块的管理. 手工弊端: 1.项目业务复杂度高,回归测试工作量大2.单个接口功能比 ...

  5. CF D. Beautiful numbers (数位dp)

    http://codeforces.com/problemset/problem/55/D Beautiful Numbers : 这个数能整除它的全部位上非零整数.问[l,r]之间的Beautifu ...

  6. cmd执行调用打开文件

    Process p = new Process();//新进程 p.StartInfo.FileName = "cmd.exe";//打开cmd程序 p.StartInfo.Use ...

  7. GammaRay 是一个允许你查看 Qt 应用程序甚至在某种程度上修改它的独特应用,可谓是 Debugger 的良好补充

    GammaRay is a tool to poke around in a Qt-application and also to manipulate the application to some ...

  8. iOS- &quot;unacceptable content-type: text/plain&quot;等content-type bug解决方式

    常常在使用AFN的时候会出现content-type错误,缺少请求类型,比方"unacceptable content-type: text/plain" 解决方法: 1.在网络请 ...

  9. 通过ip获取地址

    <?php /** * IP 地理位置查询类 * * @author 马秉尧 * @version 1.5 * @copyright 2005 CoolCode.CN */ class IpLo ...

  10. Scrapy中的UA池,代理池,以及selenium的应用

    UA池 代理池 selenium在Scrapy中的应用 UA池 - 下载中间件: - 下载中间件(Downloader Middlewares) 位于scrapy引擎和下载器之间的一层组件. - 作用 ...