hdu 5095 多项式模拟+有坑
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 多项式模拟+有坑的更多相关文章
- hdu 6034 贪心模拟 好坑
关键在排序!!! 数组间的排序会超时,所以需要把一个数组映射成一个数字,就可以了 #include <bits/stdc++.h> using namespace std; typedef ...
- 【NOI2013模拟】坑带的树(仙人球的同构+圆方树乱搞+计数+HASH)
[NOI2013模拟]坑带的树 题意: 求\(n\)个点,\(m\)条边的同构仙人球个数. \(n\le 1000\) 这是一道怎么看怎么不可做的题. 这种题,肯定是圆方树啦~ 好,那么首先转为广义圆 ...
- HDU 5095 Linearization of the kernel functions in SVM(模拟)
主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=5095 Problem Description SVM(Support Vector Machine) ...
- 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次项的系数.给出 ...
- 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 ...
- hdu 1296 Polynomial Problem(多项式模拟)
Problem Description We have learned how to obtain the value of a polynomial when we were a middle sc ...
- 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). ...
- HDU 4121 Xiangqi 模拟题
Xiangqi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4121 ...
- Linearization of the kernel functions in SVM(多项式模拟)
Description SVM(Support Vector Machine)is an important classification tool, which has a wide range o ...
随机推荐
- Centos7 上安装 FastDFS
1.安装gcc(编译时需要) FastDFS是C语言开发,安装FastDFS需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc yum install -y gcc ...
- 神啊!PS是你这样用的吗?
对于古典油画名作,人们总是持欣赏的态度去观看.能流传至今的作品,也都是当时的名作. 不过,乌克兰艺术家 Alexey Kondakov 却不是这样的,在他手中,那些世界名画也不过是他恶搞的素材罢了. ...
- Spring Boot学习笔记:kafka应用
Kafka作为众多Java消息中间件之一,有诸多优点.本文讲解Kafka的应用.学习一个新的知识点,建议先找一个demo,越简单越好的demo,跑通这个demo,了解大致原理,然后在分析细节,详细了解 ...
- ''TclError: no display name and no $DISPLAY environment variable''解决方法
在模块前写入一下代码: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt 具体解释见 http://m ...
- 【Erlang】源码安装
Erlang介绍 Erlang(['ə:læŋ])是一种通用的面向并发的编程语言,它由瑞典电信设备制造商爱立信所辖的CS-Lab开发,目的是创造一种可以应对大规模并发活动的编程语言和运行环境. Erl ...
- 【Redis】Redis cluster集群搭建
Redis集群基本介绍 Redis 集群是一个可以在多个 Redis 节点之间进行数据共享的设施installation. Redis 集群不支持那些需要同时处理多个键的 Redis 命令, 因为执行 ...
- Softmax && Cross-entropy Error
softmax 函数,被称为 归一化指数函数,是sigmoid函数的推广. 它将向量等比压缩到[0, 1]之间,所有元素和为1. 图解: Example: softmax([1, 2, 3, 4, 1 ...
- xml 转 数组
function xml_to_array($xml){ if(!$xml){ return false; } //将XML转为array //禁止引用外部xml实体 libxml_disable_e ...
- 虚拟机 与 主机 Ping 中的设置
这段时间是学习华清远见的Linux A8 关于Linux移植,遇到虚拟机与主机Ping不通.经查阅后总结出以下 VM中设置. “虚拟机设置-->硬件--> 网络适配器--> 桥接模式 ...
- vue.js实战(文摘)
---------------第1篇 基础篇 第1章 初始vue.js 第2章 数据绑定和第一个vue应用 第3章 计算属性 第4章 v-bind及class与style绑定 第5章 内置命令 第6章 ...