2012年软件大赛校内选拔赛
2012-12-09 10:52
232 查看
1、(10分)求20+21+22+23+…+2n的和,n=20。
2、(10分)1、6、9三个数字,排列组合后能产生多少个平方数(例如:3的平方为9,则9为平方数)?用程序判断并将结果打印输出。
3、(20分)Excel 表格中, 第12 行 4 列可表示为 R12C4, 第5 行 255 列可表示为 R5C255,还有另一种表示方式为 D12,IU5,输入 RC 格式转化为另一个种格式。
例:
INPUT:
2
R12C4
R5C255
OUTPUT:
D12
IU5
编程实现两种表示方法间的转化(第二行输入的2表示有两条RC格式需要转换)。
4、(30分)有 3 枚骰子,玩家可押 1-6 中的一个数
1) 如果有 1 个数相同,则庄家 1:1 赔偿
2) 如果有 2 个数相同,则庄家 1:2 赔偿
3) 如果有 3 个数相同,则庄家 1:6 赔偿
4) 如果押的点数与其中一个骰子的乘积,等于另外两个数的乘积,则拿回自己的本钱,即庄家不赚不赔
5) 如果上述 4 种情况均满足,则选择最佳的方式
实践证明,不管怎么样,庄家都是获利的,请模拟 50 万次,假设每次押注都是 1 元,求庄家的盈利率(赚的钱/总押注金额)。
5、(30分)ABCDE 五人安排工作日程,每人每星期工作 5 天休息 2 天
1) 必须有 3 天所有人都要上班
2) 每个人连续上班不超过 3 天,周日到周一是连续工作
3) A、C 星期三必须上班
4) B、D、E 星期天都不上班
5) A、C 一星期至少见 4 次
6) A、B、C、D 中每天必须至少有 2 人上班,输出所有从星期一到星期天可能的情况,每种情况间用空行隔开,0 代表不
上班,1 代表上班。
例:
1 0 1 1 1 0 1
1 1 0 1 1 1 0
1 0 1 1 1 0 1
1 1 0 1 1 1 0
1 1 0 1 1 1 0
//刚开始想一个一个算再加一块,后来想到了求和公式 #include <iostream> #include <cstring> using namespace std; int fun(int a,int b)//或者直接(2<<20-1或者1<<21-1) { int temp,ans; if(0==b) return 1; temp = fun(a,b/2); ans = temp*temp; if(b&1) return ans*a; else return ans; } int main() { int i,j,k; int ans = fun(2,21) - 1; cout<<ans<<endl; //while(1); return 0; }
2、(10分)1、6、9三个数字,排列组合后能产生多少个平方数(例如:3的平方为9,则9为平方数)?用程序判断并将结果打印输出。
#include <iostream> #include <algorithm> #include <cmath> using namespace std; const double eps = 0.0000000000001;// 1e-8,中间不可有乘号,阶码必须是整数 ,double后的小数点可为15位 int main() { int i,j,k; int cnt = 0; int a[] = {1,6,9}; sort(a,a+3); do { //cout<<a[0]<<a[1]<<a[2]<<endl; int temp = a[0]*100 + a[1]*10 + a[2]; double temp1 = sqrt(temp); //cout<<temp<<" "<<temp1<<endl; //if(fabs(temp1*temp1-temp)<eps)//这种方法不对,肯定输出总的全排列个数 //cnt++; double temp2 = (double)((int)temp1); if(fabs(temp1 - temp2)<eps)//若是平方数,则开放的数没有小数部分 cnt++; }while(next_permutation(a,a+3)); cout<<cnt<<endl; // while(1); return 0; }
3、(20分)Excel 表格中, 第12 行 4 列可表示为 R12C4, 第5 行 255 列可表示为 R5C255,还有另一种表示方式为 D12,IU5,输入 RC 格式转化为另一个种格式。
例:
INPUT:
2
R12C4
R5C255
OUTPUT:
D12
IU5
编程实现两种表示方法间的转化(第二行输入的2表示有两条RC格式需要转换)。
//这道题费了些神,以前也遇到过类似的但没做出来,今天我思量主要是我把自己搞得太疲惫啦 //行号直接输出就好啦,列数用栈处理下 #include <iostream> #include <algorithm> #include <cmath> #include <stack> #include <cstring> using namespace std; char str[20]; int temp1 = 0,temp2 = 0; stack <int > s; void fun() { int i,j; int len = strlen(str); temp1 = temp2 = 0; for(i=1; i<len; i++) { if(isdigit(str[i])) temp1 = temp1*10 + str[i] - '0'; else break; } for(j=i+1; j<len; j++)//注意j是从(i+1)开始的,不是i { if(isdigit(str[j]))//原来直接复制过来啦,里面的i没改成j temp2 = temp2*10 + str[j] - '0'; } while(temp2>0) { int temp = temp2%26; s.push(temp); temp2 /= 26; } } int main() { int i,j,k; int T; cin>>T; while(T--) { temp1 = temp2 = 0; memset(str,0,sizeof(str)); // while(!s.empty()) // s.pop(); cin>>str; fun(); // for(i=0; i<s.size(); i++) while(!s.empty()) { char ch = (char)(s.top() + 64); cout<<ch; s.pop(); } cout<<temp1<<endl; } return 0; }
4、(30分)有 3 枚骰子,玩家可押 1-6 中的一个数
1) 如果有 1 个数相同,则庄家 1:1 赔偿
2) 如果有 2 个数相同,则庄家 1:2 赔偿
3) 如果有 3 个数相同,则庄家 1:6 赔偿
4) 如果押的点数与其中一个骰子的乘积,等于另外两个数的乘积,则拿回自己的本钱,即庄家不赚不赔
5) 如果上述 4 种情况均满足,则选择最佳的方式
实践证明,不管怎么样,庄家都是获利的,请模拟 50 万次,假设每次押注都是 1 元,求庄家的盈利率(赚的钱/总押注金额)。
5、(30分)ABCDE 五人安排工作日程,每人每星期工作 5 天休息 2 天
1) 必须有 3 天所有人都要上班
2) 每个人连续上班不超过 3 天,周日到周一是连续工作
3) A、C 星期三必须上班
4) B、D、E 星期天都不上班
5) A、C 一星期至少见 4 次
6) A、B、C、D 中每天必须至少有 2 人上班,输出所有从星期一到星期天可能的情况,每种情况间用空行隔开,0 代表不
上班,1 代表上班。
例:
1 0 1 1 1 0 1
1 1 0 1 1 1 0
1 0 1 1 1 0 1
1 1 0 1 1 1 0
1 1 0 1 1 1 0
相关文章推荐
- 2012年软件大赛校内选拔赛
- XMUT第七届蓝桥杯全国软件和信息技术专业人才大赛校内选拔赛模拟赛
- 2011届蓝点杯全国软件设计与开发大赛 选拔赛获奖名单
- 第五届“蓝桥杯”全国软件 校内选拔赛试题(Java组)2。
- 第六届蓝桥杯大赛个人赛(软件类)校内选拔题目X^X=10
- 第六届蓝桥杯大赛个人赛(软件类)校内选拔题目X^X=10
- 第五届“蓝桥杯”全国软件和 校内选拔赛试题(Java组)4、计算蔬菜总价
- 第五届“蓝桥杯”全国软件 校内选拔赛试题(Java组)9。
- 第五届“蓝桥杯”全国软件 校内选拔赛试题(Java组)10.
- 第五届“蓝桥杯”全国软件 校内选拔赛试题(Java组)11、(18分) 身份证的奥秘
- 2012年第三届蓝桥杯全国软件大赛c++预赛 题目及参考答案
- 第六届蓝桥杯大赛个人赛(软件类)校内选拔题目\Java大学B组\2题 调和级数
- 2012全国软件大赛蓝桥杯选拔赛04题
- 2012年华为软件校园招聘编程测验(又名:2012华为创新杯编程大赛)软件Java语言类原题与解答
- 第六届蓝桥杯大赛个人赛(软件类)校内选拔题目\Java大学B组\3题 x的x次幂等于10
- 软件大赛校内选拔赛题:蛇形填数
- 第六届蓝桥杯大赛个人赛(软件类)校内选拔题目\Java大学B组\1题
- 大数相乘的一种思路(2012年软件设计大赛的启思)
- 第五届“蓝桥杯”全国软件校内选拔赛试题(Java组)1、素数问题
- 第十五届全国大学生外交外事礼仪大赛校内选拔赛试题