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 ...
随机推荐
- Servlet 3.0 规范(二)注解驱动和异步请求
Servlet 3.0 规范(二)注解驱动和异步请求 在 Servlet 3.0 时支持注解启动,不再需要 web.xml 配制文件. 一.Servlet 3.0 组件 Servlet 容器的组件大致 ...
- java itext 报错 com.itextpdf.text.DocumentException: Font 'STSong-Light' with 'UniGB-UCS2-H'
com.itextpdf.text.DocumentException: Font 'STSong-Light' with 'UniGB-UCS2-H' 解决方案 <dependency> ...
- Ubuntu上搭建Hadoop环境(单机模式+伪分布模式) (转载)
Hadoop在处理海量数据分析方面具有独天优势.今天花了在自己的Linux上搭建了伪分布模式,期间经历很多曲折,现在将经验总结如下. 首先,了解Hadoop的三种安装模式: 1. 单机模式. 单机模式 ...
- 解疑网络监控卡壳 视觉体验400ms延时
http://security.zol.com.cn/413/4130220.html 我的眼睛可以轻松判断出400ms延时误差,你可以吗?很多用户都反映手机移动监控.PC远程监控视频会卡顿,抛开设备 ...
- canvas 实现飘浮桥效果
var canvas = document.getElementById('canvas'); var cxt = canvas.getContext('2d'); var timer; var iS ...
- 惊讶于word 的流畅
word 这个产品 的操作流畅 比自家产品OneNote 比wps 强的太多 用后的体验是,再用其他的编译文字的软件,便感觉操作不畅,不流利,不舒服.(使人曾经沧海难为水,自然而然的不用别人的产品,w ...
- python学习 day5 (3月6日)
字典映射,{}键值对,key 唯一的 ,可哈希,容器型数据类型 可变的(不可哈希): 字典 列表 集合 都不可做键 不可变的(可哈希): 数字 字符串 bool 元组 frozeset() 可以做键 ...
- Unity2017新功能Sprite Atlas详解
Sprite Atlas(精灵图集)Sprite Atlas 针对现有的图集打包系统Sprite Packer在性能和易用性上的不足,进行了全面改善.除此之外,相比Sprite Packer,Spri ...
- 再读c++primer plus 006
使用类: 1.重载限制:(1)重载后的运算符必须至少有一个操作数是用户定义的类型,这将防止用户为标准类型重载运算符 (2)使用运算符时不能违反运算符原来的语法规则,不能修改运算符的优先级 (3)不能创 ...
- django rest framemark
一 内容回顾 1 开发者模式 普通开发方式:前后端放在一起开发 前后端分离:前后端只通过 JSON 来交流,组件化.工程化不需要依赖后端去实现 2 后端开发:为前端提供url接口,也就是API或者接口 ...