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. 剑指offer自学系列(二)

    题目描述: 在一个长度为n的数组里的所有数字都在0到n-1的范围内,数组中某些数字是重复的,但不知道有几个数字是重复的,也不知道每个数字重复几次,请找出数组中任一个重复的数字,例如,如果输入长度为7的 ...

  2. 基于springboot实现Java阿里短信发送

    1.接口TestController import java.util.Random; import com.aliyuncs.DefaultAcsClient; import com.aliyunc ...

  3. 洛谷 三月月赛 B

    搞出每一位与前一位的差,然后区间修改只是会影响区间的端点,所以只修改一下端点的值就好. %%%高一神犇线段树 #include<bits/stdc++.h> #define N 10000 ...

  4. 洛谷[Luogu] 普及村-简单的模拟总结

    题目列表 注明:Level值代表在本难度下的排行.(纯粹本蒟蒻主观评判)注明:Level值代表在本难度下的排行.(纯粹本蒟蒻主观评判)注明:Level值代表在本难度下的排行.(纯粹本蒟蒻主观评判) P ...

  5. 160-PHP 文本替换函数str_replace(一)

    <?php $str='Hello world!'; //定义源字符串 $search='o'; //定义将被替换的字符 $replace='O'; //定义替换的字符串 $res=str_re ...

  6. MESI缓存一致性协议

    整理一下一些计算机的基础概念. 概念 MESI(Modified, Exclusive, Shared, Invalid) 也称 Illinois 协议, 由美帝UIUC(University of ...

  7. Windows2008R2安装DNS和SQLServer200r2服务 (9.18第七天)

    原文网址:https://www.cnblogs.com/yankaohaitaiwei/p/11538205.html 二.IIS搭建web服务器 1.格式化D盘,一定要选择NTFS!!!不然后面添 ...

  8. JS - 解决引入 js 文件无效的问题

    增加 type 即可  <script type="text/javascript" src="....js"></script>

  9. 并发 ping

    参考 [root@RS2 ~]# cat .sh #!/bin/bash # --, by wwy #------------------------------------------------- ...

  10. 【5分钟+】计算机系统结构:CPU性能公式

    计算机系统结构:CPU性能公式 基础知识 CPU 时间:一个程序在 CPU 上运行的时间.(不包括I/O时间) 主频.时钟频率:CPU 内部主时钟的频率,表示1秒可以完成多少个周期. 例如,主频为 4 ...