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等等

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define clr0(x) memset(x,0,sizeof(x))
#define clr1(x) memset(x,-1,sizeof(x))
#define eps 1e-9
const double pi = acos(-1.0);
typedef long long LL;
typedef unsigned long long ULL;
const int modo = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int inf = 0x3fffffff;
const LL _inf = 1e18;
const int maxn = 105,maxm = 10005;
int p[maxn],n,k;
char q[maxn] = {'p','q','r','u','v','w','x','y','z','\n'};
char ch[maxn];
void work()
{
for(int i = 0;i < 10;++i){
RD(p[i]);
// scanf("%s",ch);
// if(strlen(ch) > 10)
// while(1);
// sscanf(ch,"%d",&p[i]);
}
int k = 0;
while(k < 10 && p[k] == 0)k++;
if(k == 10){
puts("0");
return ;
}
if(k == 9){
printf("%d\n",p[9]);
return;
}
if(p[k] == 1)
printf("%c",q[k]);
else if(p[k] == -1)
printf("-%c",q[k]);
else
printf("%d%c",p[k],q[k]); for(int i = k+1;i < 9;++i){
if(p[i] > 1)
printf("+%d%c",p[i],q[i]);
else if(p[i] < -1)
printf("%d%c",p[i],q[i]);
else if(p[i] == 1)
printf("+%c",q[i]);
else if(p[i] == -1)
printf("-%c",q[i]);
}
if(p[9] == 0)
puts("");
else if(p[9] > 0)
printf("+%d\n",p[9]);
else
printf("%d\n",p[9]);
return;
}
int main()
{
int _;RD(_);
while(_--){
work();
}
return 0;
}

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. Python 字符串(center)

    center 描述 Python center() 返回一个原字符串居中,并使用空格填充至长度 width 的新字符串.默认填充字符为空格. 语法 center()方法语法: str.center(w ...

  2. hdu 1010(DFS) 骨头的诱惑

    http://acm.hdu.edu.cn/showproblem.php?pid=1010 题目大意从S出发,问能否在时间t的时候到达终点D,X为障碍 需要注意的是要恰好在t时刻到达,而不是在t时间 ...

  3. [Robot Framework] Jenkins上调用Rebot命令时执行报错不往下执行其他命令

    在配置jenkins job时,添加构建步骤Execute Windows batch command,输入执行rebot命令 报错信息: Call C:\Python27\Scripts\rebot ...

  4. Maximum Average Subarray II LT644

    Given an array consisting of n integers, find the contiguous subarray whose length is greater than o ...

  5. vue回到顶部组件

    html <template> <a href="javascript:;" class="toTop" @click="backT ...

  6. django网页图片验证码功能

    在一个正常的登录系统中,验证码是非常重要的,用于识别人机,毕竟我们都知道,这个世界中存在着万恶的爬虫,验证码有很多种方式,有图片的,有邮件的,有短信的,有拼图的,不管什么样的验证码,目的都是验证访问用 ...

  7. mybatis缓存(一,二级别)

    数据查找过程: 二级缓存(默认关闭) -> 一级缓存(默认开启) -> 数据库 一级缓存: 一级缓存是SqlSession自带的.SqlSession对象被创建,一级缓存就存在了.//是针 ...

  8. JS高级- OOP-ES5

    1. OOP 面向对象三大特点: 封装,继承,多态 封装: 问题: 构造函数可重用代码和结构定义,但无法节约内存 为什么: 放在构造函数内的方法定义,每new一次,都会反复创建副本——浪费内存 解决: ...

  9. kbmmw 5.06.20 发布

    经过1个多月的测试,终于发布正式版. 5.06.20 July 11 2018           Important notes (changes that may break existing c ...

  10. 51.从首页内容跳转到第二个Tabbar控制器(controller)

    TabBarController: 创建TabBar的控制器 注意:在点击的内容方法页面,添加头文件 #import "TabBarController.h" #import &q ...