http://acm.hdu.edu.cn/showproblem.php?pid=5095

就是把ax^2 + by^2 + cy^2 + dxy + eyz + fzx + gx + hy + iz + j转换成ap + bq + cr + du + ev + fw + gx + hy + iz + j

注意的地方就是开头不要有+,系数为0不输出,系数为1的话不能输出系数除非指数为0等等

  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <string>
  6. #include <queue>
  7. #include <map>
  8. #include <iostream>
  9. #include <algorithm>
  10. using namespace std;
  11. #define RD(x) scanf("%d",&x)
  12. #define RD2(x,y) scanf("%d%d",&x,&y)
  13. #define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
  14. #define clr0(x) memset(x,0,sizeof(x))
  15. #define clr1(x) memset(x,-1,sizeof(x))
  16. #define eps 1e-9
  17. const double pi = acos(-1.0);
  18. typedef long long LL;
  19. typedef unsigned long long ULL;
  20. const int modo = 1e9 + 7;
  21. const int INF = 0x3f3f3f3f;
  22. const int inf = 0x3fffffff;
  23. const LL _inf = 1e18;
  24. const int maxn = 105,maxm = 10005;
  25. int p[maxn],n,k;
  26. char q[maxn] = {'p','q','r','u','v','w','x','y','z','\n'};
  27. char ch[maxn];
  28. void work()
  29. {
  30. for(int i = 0;i < 10;++i){
  31. RD(p[i]);
  32. // scanf("%s",ch);
  33. // if(strlen(ch) > 10)
  34. // while(1);
  35. // sscanf(ch,"%d",&p[i]);
  36. }
  37. int k = 0;
  38. while(k < 10 && p[k] == 0)k++;
  39. if(k == 10){
  40. puts("0");
  41. return ;
  42. }
  43. if(k == 9){
  44. printf("%d\n",p[9]);
  45. return;
  46. }
  47. if(p[k] == 1)
  48. printf("%c",q[k]);
  49. else if(p[k] == -1)
  50. printf("-%c",q[k]);
  51. else
  52. printf("%d%c",p[k],q[k]);
  53.  
  54. for(int i = k+1;i < 9;++i){
  55. if(p[i] > 1)
  56. printf("+%d%c",p[i],q[i]);
  57. else if(p[i] < -1)
  58. printf("%d%c",p[i],q[i]);
  59. else if(p[i] == 1)
  60. printf("+%c",q[i]);
  61. else if(p[i] == -1)
  62. printf("-%c",q[i]);
  63. }
  64. if(p[9] == 0)
  65. puts("");
  66. else if(p[9] > 0)
  67. printf("+%d\n",p[9]);
  68. else
  69. printf("%d\n",p[9]);
  70. return;
  71. }
  72. int main()
  73. {
  74. int _;RD(_);
  75. while(_--){
  76. work();
  77. }
  78. return 0;
  79. }

hdu 5095 多项式模拟+有坑的更多相关文章

  1. hdu 6034 贪心模拟 好坑

    关键在排序!!! 数组间的排序会超时,所以需要把一个数组映射成一个数字,就可以了 #include <bits/stdc++.h> using namespace std; typedef ...

  2. 【NOI2013模拟】坑带的树(仙人球的同构+圆方树乱搞+计数+HASH)

    [NOI2013模拟]坑带的树 题意: 求\(n\)个点,\(m\)条边的同构仙人球个数. \(n\le 1000\) 这是一道怎么看怎么不可做的题. 这种题,肯定是圆方树啦~ 好,那么首先转为广义圆 ...

  3. HDU 5095 Linearization of the kernel functions in SVM(模拟)

    主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=5095 Problem Description SVM(Support Vector Machine) ...

  4. TYVJ P1103 多项式输出 Label:模拟 有点儿坑

    描述 一元 n 次多项式可用如下的表达式表示:  f(x)=an*x^n+an-1*x^n-1+...+a1*x+a0,an<>0其中,ai*a^x 称为i次项,ai称为i次项的系数.给出 ...

  5. HDU 5095 Linearization of the kernel functions in SVM (坑水)

    比较坑的水题,首项前面的符号,-1,+1,只有数字项的时候要输出0. 感受一下这些数据 160 0 0 0 0 0 0 0 0 -10 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 ...

  6. hdu 1296 Polynomial Problem(多项式模拟)

    Problem Description We have learned how to obtain the value of a polynomial when we were a middle sc ...

  7. hdu 5095 Linearization of the kernel functions in SVM(模拟,分类清楚就行)

    题意: INPUT: The input of the first line is an integer T, which is the number of test data (T<120). ...

  8. HDU 4121 Xiangqi 模拟题

    Xiangqi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4121 ...

  9. Linearization of the kernel functions in SVM(多项式模拟)

    Description SVM(Support Vector Machine)is an important classification tool, which has a wide range o ...

随机推荐

  1. IDEA 中javadoc插件不能设置的问题

    解决方案 1.手动下载插件 https://github.com/ranzou06/intellij-javadocs/blob/master/intellij-javadocs.zip?raw=tr ...

  2. Executors提供的四种线程池

    Java 5+中的Executor接口定义一个执行线程的工具.它的子类型即线程池接口是ExecutorService.要配置一个线程池是比较复杂的,尤其是对于线程池的原理不是很清楚的情况下,因此在工具 ...

  3. MacDev.GarbageCollectionIsDeprecated-WhenXcodeCompileMacAppProject

    Garbage Collection is not supported 当Xcode编译Mac OSX App时报错:"Garbage Collection is not supported ...

  4. Android.ApplicationCrash

    1. 如何调试分析Android中发生的tombstone http://www.360doc.com/content/12/1017/10/7580194_241974419.shtml tombs ...

  5. 探索未知种族之osg类生物---器官初始化二

    那我们回到ViewerBase::frame函数中来,继续看看为什么osg生命刚刚出生的时候会大哭,除了初始化了eventQuene和cameraManipulator之外还对那些器官进行了初始化.在 ...

  6. 如何让网站在百度有LOGO展示

    什么叫没有了网站logo?准确来说应该是网站索引logo,这个logo确实网站很好的一个展示窗口,我以长沙seo关键词为例,我给大家举例! 我输入长沙SEO,出来的百度索引图,原本所有我标红的框子里都 ...

  7. BZOJ 2733 [HNOI2012]永无乡 - 启发式合并主席树

    Description 1: 查询一个集合内的K大值 2: 合并两个集合 Solution 启发式合并主席树板子 Code #include<cstdio> #include<cst ...

  8. PS合成的5个要点:场景、对比、氛围、模糊、纹理

    是否觉得做合成打开PS之后无处下手,做完之后总觉得缺少故事情节?这一次分享的5个要点,是个人觉得需要重视的,每一点都有一个案例来让作品变得多一份惊喜.(申明:文中素材均来自网络,这里仅作分享交流作用) ...

  9. sql条件查询-日期比较(取年月部分)

    查询当年当月的数据: select * from compalete_task where to_Char(create_date,'yyyyMM') = to_Char(sysdate,'yyyyM ...

  10. flask在其他文件中添加路由

    应用文件为:app.py from flask import Flask app = Flask(__name__) @app.route("/") def hello(): re ...