A 1009 Product of Polynomials (25 point(s))

  读懂题意就行。

 #include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm> using namespace std;
typedef struct NODE
{
int exp;
double coe;
NODE(){exp = ; coe = ;}
NODE(int e, double v):exp(e),coe(v){}
}node;
vector<node> poly1, poly2;
double rstPoly[]={};
int main()
{
int N, tmpExp;
double tmpCoe;
cin >> N;
for(int i = ; i < N; ++ i)
{
cin >> tmpExp >> tmpCoe;
poly1.push_back(NODE(tmpExp, tmpCoe));
}
cin >> N;
for(int i = ; i < N; ++ i)
{
cin >> tmpExp >> tmpCoe;
poly2.push_back(NODE(tmpExp, tmpCoe));
}
for(int i = ; i < poly1.size(); ++i)
for(int j = ; j < poly2.size(); ++ j)
rstPoly[poly1[i].exp+poly2[j].exp] += poly1[i].coe*poly2[j].coe;
int cnt = ;
for(int i = ; i < ; ++ i)
if(rstPoly[i] != )
cnt++;
cout << cnt;
for(int i = ; i >= ; -- i)
if(rstPoly[i] != )
{
printf(" %d %.1f", i, rstPoly[i]);
}
return ;
}

A 1010 Radix (25 point(s))

  这道题目相当有趣,坑的莫名其妙,哈哈哈。

  注意:1.数的范围,10位数字,int 不够用

     2.超时,因而不能从小到大递增取进制数

       3.二分法,最大进制和最小进制的确定

       4.超限,在找进制数的过程中,过大的进制数会发生超限,注意这种情况

     5.待确定进制数只有一位,此时需要注意取最小进制

 #include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm> using namespace std;
long long toNum(char c)
{
return isdigit(c) ? c-'' : c-'a'+;
}
long long strRadixToNum(string tmpStr, long long radix)
{
long long tmpNum = , ant = ;
for(int i = tmpStr.size()-; i >= ; -- i)
{
tmpNum += toNum(tmpStr[i])*ant;
if(tmpNum < || ant < )
return -;
ant *= radix;
}
return tmpNum;
}
long long minRadix(string tmpStr)
{
char tmpChar = ;
for(int i = ; i < tmpStr.size(); ++ i)
{
if(tmpStr[i] > tmpChar)
tmpChar = tmpStr[i];
}
return toNum(tmpChar) + ;
}
int main()
{
long long tag, radix, tmpNum, tmpTarget, lowRadix, highRadix;
string N1, N2;
cin >> N1 >> N2 >> tag >> radix;
//算出进制已经确定的数作为目标值
//并且 找出未确定进制的数的最小进制
if(tag == )
swap(N1, N2);
highRadix = tmpTarget = strRadixToNum(N1, radix);
lowRadix = max((long long) , minRadix(N2));
while(lowRadix <= highRadix)
{
long long midRadix = (lowRadix + highRadix)/;
long long tmpNum1 = strRadixToNum(N2, midRadix);
if(tmpNum1 >= tmpTarget ||tmpNum1 == -)
highRadix = midRadix - ;
else
lowRadix = midRadix + ;
}
if(strRadixToNum(N2, lowRadix) == tmpTarget)
cout << lowRadix;
else
cout << "Impossible";
return ;
}

A 1011 World Cup Betting (20 point(s))

 #include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm> using namespace std;
int main()
{
double sum = 0.65, tmpW, tmpT, tmpL;
for(int i = ; i < ; ++ i)
{
cin >> tmpW >> tmpT >> tmpL;
if(tmpW > max(tmpT, tmpL))
{
cout << "W ";
sum *= tmpW;
}
else if(tmpT > max(tmpW, tmpL))
{
cout << "T ";
sum *= tmpT;
}
else
{
cout << "L ";
sum *= tmpL;;
}
}
printf("%.2f", (sum-)*);
return ;
}

A 1012 The Best Rank (25 point(s))

  注意:1.排名的问题,相同成绩同一排名

     2.最佳排名相同,按所给优先级

 #include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <functional> using namespace std;
typedef struct NODE
{
int id, math, cCode, aver, english;
}node;
vector<int> cCodeVec, mathVec, engVec, averVec;
unordered_map<int, node> nodeMap;
unordered_map<int, int> nodeTableMap;
void getBestRank(int u)
{
int type = , rank, cnt;
char typeStr[]="ACME";
node tmpNode = nodeMap[u];
cnt = ;
for(auto it = averVec.begin(); it != averVec.end(); ++it, ++cnt)
if(*it == tmpNode.aver)
{
type = ; rank = cnt;break;
}
cnt = ;
for(auto it = cCodeVec.begin(); it != cCodeVec.end(); ++it, ++cnt)
if(*it == tmpNode.cCode && cnt < rank)
{
type = ; rank = cnt;break;
}
cnt = ;
for(auto it = mathVec.begin(); it != mathVec.end(); ++it, ++cnt)
if(*it == tmpNode.math && cnt < rank)
{
type = ; rank = cnt;break;
}
cnt = ;
for(auto it = engVec.begin(); it != engVec.end(); ++it, ++cnt)
if(*it == tmpNode.english && cnt < rank)
{
type = ; rank = cnt;break;
}
printf("%d %c\n", rank, typeStr[type]);
}
int main()
{
int N, M;
node tmpNode;
cin >> N >> M;
for(int i = ; i < N; ++i)
{
cin >> tmpNode.id >> tmpNode.cCode >> tmpNode.math >> tmpNode.english;
tmpNode.aver = (tmpNode.cCode + tmpNode.math + tmpNode.english+1.5)/;
cCodeVec.push_back(tmpNode.cCode); mathVec.push_back(tmpNode.math);
engVec.push_back(tmpNode.english); averVec.push_back(tmpNode.aver);
nodeMap[tmpNode.id] = tmpNode;nodeTableMap[tmpNode.id] = ;
}
sort(averVec.begin(), averVec.end(), greater<int>());
sort(cCodeVec.begin(), cCodeVec.end(), greater<int>());
sort(mathVec.begin(), mathVec.end(), greater<int>());
sort(engVec.begin(), engVec.end(), greater<int>());
for(int i = ; i < M; ++ i)
{
cin >> tmpNode.id;
if(nodeTableMap[tmpNode.id] > )
getBestRank(tmpNode.id);
else
cout << "N/A" << endl;
}
return ;
}

PAT A1009-1012的更多相关文章

  1. PAT甲级1012. The Best Rank

    PAT甲级1012. The Best Rank 题意: 为了评估我们第一年的CS专业学生的表现,我们只考虑他们的三个课程的成绩:C - C编程语言,M - 数学(微积分或线性代数)和E - 英语.同 ...

  2. PAT 乙级 1012

    题目 题目地址:PAT 乙级 1012 思路 最后一个测试点怎么也过不了,问题在于A2的判断,不能单纯地以0作为判断条件:假设满足A2条件的只有两个数6和6,计算结果仍然是0,但是输出A2的值是0不是 ...

  3. 【PAT】1012. The Best Rank (25)

    题目链接: http://pat.zju.edu.cn/contests/pat-a-practise/1012 题目描述: To evaluate the performance of our fi ...

  4. PAT乙级 1012. 数字分类 (20)

    1012. 数字分类 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 给定一系列正整数,请按要求对数字进 ...

  5. [C++]PAT乙级1012.数字分类 (20/20)

    /* 1012. 数字分类 (20) 给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字: A1 = 能被5整除的数字中所有偶数的和: A2 = 将被5除后余1的数字按给出顺序进行交错求和, ...

  6. PAT Basic 1012

    1012 数字分类 (20 分) 给定一系列正整数,请按要求对数字进行分类,并输出以下 5 个数字: A​1​​ = 能被 5 整除的数字中所有偶数的和: A​2​​ = 将被 5 除后余 1 的数字 ...

  7. PAT 乙级 1012 数字分类 (20) C++版

    1012. 数字分类 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 给定一系列正整数,请按要求对数字进 ...

  8. PAT甲 1012. The Best Rank (25) 2016-09-09 23:09 28人阅读 评论(0) 收藏

    1012. The Best Rank (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...

  9. PAT乙级1012

    1012 数字分类 (20 分)   给定一系列正整数,请按要求对数字进行分类,并输出以下 5 个数字: A​1​​ = 能被 5 整除的数字中所有偶数的和: A​2​​ = 将被 5 除后余 1 的 ...

  10. 【PAT】1012. 数字分类 (20)

    1012. 数字分类 (20) 给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字: A1 = 能被5整除的数字中所有偶数的和: A2 = 将被5除后余1的数字按给出顺序进行交错求和,即计算 ...

随机推荐

  1. LeetCode1046 最后一块石头的重量(贪心—Java优先队列简单应用)

    题目: 有一堆石头,每块石头的重量都是正整数. 每一回合,从中选出两块最重的石头,然后将它们一起粉碎.假设石头的重量分别为 x 和 y,且 x <= y.那么粉碎的可能结果如下: 如果 x == ...

  2. ubuntu下pip的安装、升级和使用

    系统虽然自带了不同版本的python,但都没有安装pip,pyhton2.7下使用的是pip2,python3.5下使用的是pip3.下面是各自安装命令. 安装 pip2: sudo apt-get ...

  3. poker2的配置使用

    1.映射Win键的诸多功能 切换输入法,shift+alt本身已经支持了,所以Win+Space就不管了 Win+Space映射为Fn+Space Win+E映射为Fn+E Win+R映射为Fn+R ...

  4. .NET 一次读取几百条数据优化,从原来30分钟优化到30秒

    1.全部数据读取到内存, 不要使用string,而是使用stringbuilder,stringbuilder的效率非常高 2.添加到数据库 不要使用excute,而是使用事务,几百万条数据会请求数据 ...

  5. Elasticsearch 教程

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  6. junit基础学习之-测试service层(3)

    测试步骤: 在之前的文章中已经加了junit的环境,这就不需要了. 1.加载junit类,spring配置文件,指明junit测试器,@Runwith 2.定义变量,service,不可以使用spri ...

  7. python --- 对于需要关联的接口处理方法

    1.unittest对于需要关联的请求,怎么处理(如购物接口,需要先登录) a)把登录请求写到测试用例类的setUP函数中,这样每次调用测试用例,都会先执行setUP函数 b)全局变量的形式声明. c ...

  8. 每天一点点之 taro 框架开发 - 事件处理与样式表

    1.方法调用 state = { name:'张三' } test(){ this.state.name } <button onClick={ this.test.bind(this) } / ...

  9. git仓库管理

    删除本地仓库当前关联的无效远程地址,再为本地仓库添加新的远程仓库地址 git remote -v //查看git对应的远程仓库地址 git remote rm origin //删除关联对应的远程仓库 ...

  10. HTML笔记及案例

    - 了解什么是标记语言 - 了解HTML主要特性,主要变化以及发展趋势 - 了解HTML的结构标签 - 掌握HTML的主要标签(字体,图片,列表,链接,表单等标签) ### 1.网站信息页面 #### ...