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 ...
随机推荐
- IDEA 中javadoc插件不能设置的问题
解决方案 1.手动下载插件 https://github.com/ranzou06/intellij-javadocs/blob/master/intellij-javadocs.zip?raw=tr ...
- Executors提供的四种线程池
Java 5+中的Executor接口定义一个执行线程的工具.它的子类型即线程池接口是ExecutorService.要配置一个线程池是比较复杂的,尤其是对于线程池的原理不是很清楚的情况下,因此在工具 ...
- MacDev.GarbageCollectionIsDeprecated-WhenXcodeCompileMacAppProject
Garbage Collection is not supported 当Xcode编译Mac OSX App时报错:"Garbage Collection is not supported ...
- Android.ApplicationCrash
1. 如何调试分析Android中发生的tombstone http://www.360doc.com/content/12/1017/10/7580194_241974419.shtml tombs ...
- 探索未知种族之osg类生物---器官初始化二
那我们回到ViewerBase::frame函数中来,继续看看为什么osg生命刚刚出生的时候会大哭,除了初始化了eventQuene和cameraManipulator之外还对那些器官进行了初始化.在 ...
- 如何让网站在百度有LOGO展示
什么叫没有了网站logo?准确来说应该是网站索引logo,这个logo确实网站很好的一个展示窗口,我以长沙seo关键词为例,我给大家举例! 我输入长沙SEO,出来的百度索引图,原本所有我标红的框子里都 ...
- BZOJ 2733 [HNOI2012]永无乡 - 启发式合并主席树
Description 1: 查询一个集合内的K大值 2: 合并两个集合 Solution 启发式合并主席树板子 Code #include<cstdio> #include<cst ...
- PS合成的5个要点:场景、对比、氛围、模糊、纹理
是否觉得做合成打开PS之后无处下手,做完之后总觉得缺少故事情节?这一次分享的5个要点,是个人觉得需要重视的,每一点都有一个案例来让作品变得多一份惊喜.(申明:文中素材均来自网络,这里仅作分享交流作用) ...
- sql条件查询-日期比较(取年月部分)
查询当年当月的数据: select * from compalete_task where to_Char(create_date,'yyyyMM') = to_Char(sysdate,'yyyyM ...
- flask在其他文件中添加路由
应用文件为:app.py from flask import Flask app = Flask(__name__) @app.route("/") def hello(): re ...