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. hdu 4717(三分) The Moving Points

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 n个点,给出初始坐标和移动的速度和移动的方向,求在哪一时刻任意两点之间的距离的最大值的最小. 对于最 ...

  2. RabbitMQ 的基本介绍

    RabbitMQ官网教程:http://www.rabbitmq.com/getstarted.html RabbitMQ 是一个由 Erlang 语言开发的 AMQP 的开源实现.AMQP :Adv ...

  3. windows下git的使用方法(码云)

    这表文章主要是用了可视化操作: 使用命令行操作:https://www.cnblogs.com/mswyf/p/9370238.html 一.安装Git Bash 为了在windows下使用Git,我 ...

  4. 关于出现“对不起,您安装的不是正版应用...”的解决方法

    由于Discuz X版本增加了对插件的版本检测,在安装时,可能会出现:"对不起,您安装的不是正版应用,安装程序无法继续执行"的提示,如下图: 唱唱反调小编在此给大家分享解决方法: ...

  5. ipv6地址累加函数

    #include <stdio.h> #include <arpa/inet.h> int main() { int i; int ret; struct in6_addr a ...

  6. Laravel Relationship Events

    Laravel Relationship Events is a package by Viacheslav Ostrovskiy that adds extra model relationship ...

  7. java连接数据库以及连接参数格式

    //链接数据库代码部分  下面具有连接的基本参数可以对照修改(参数存放在file下面的database.properties下面) //参数存放在file下面的database.properties下 ...

  8. android 使用UDP发送数据 DatagramSocket 创建对象为null

    DatagramSocket socket=null; try { socket = new DatagramSocket();  //这里创建对象为空 } catch (SocketExceptio ...

  9. Android中关于使用空格对齐文字

    前言:今日编写新项目UI时,突然遇到文本有长有短无法对齐的问题(汗,以前竟从未遇到也从未考虑过这小小的问题),在资源文件中尝试Tab键.space空格键,发现效果都不能很好的实现,无奈只得请求度娘的协 ...

  10. Android Makefile中是 如何识别 TARGET_PRODUCT 的

    http://blog.csdn.net/stevenliyong/article/details/5285334 今天有时间小看一下Android 的Makefile, 终于稍有明白Android ...