2010年上海世界博览会(Expo2010),是第41届世界博览会。于2010年5月1日至10月31日期间,在中国上海市举行。本次世博会也是由中国举办的首届世界博览会。上海世博会以“城市,让生活更美好”(Better City,Better Life)为主题,将充分探索21世纪城市生活。
这次世博会总投资达450亿人民币,创造了世界博览会史上的最大规模记录。吸引200个国家和国际组织参展。预计有7000万人次的参观者。
为了更好地接待在这期间来自世界各地的参观者,如何合理安排各宾馆的住房问题提到了日程。组委会已接到了大量的客户住宿定单,每张定单的内容包括要住宿的房间数,开始住宿时间和要住的天数。为了便于整个城市各宾馆的管理,组委会希望对这些定单进行安排,目的是用尽可能少的房间来满足这些定单,以便空出更多的房间用于安排流动游客。
组委会请求DR.Kong来完成这个任务,对这些定单进行合理安排,使得满足这些定单要求的房间数最少。
假设:某个定单上的游客一旦被安排到某房间,在他预定住宿的期间内是不换房间的。为了简化描述,定单上的开始住宿时间为距离现在的第几天。例如,定单为(10,30,5)表示游客要求使用10个房间,第30天开始连住5天。
1 3 3 10 4 4 9 3 3 12 6
7
AC代码:
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 200; int room[maxn]; int main() { int t, n; scanf("%d", &t); while(t--) { memset(room, 0, sizeof(room)); scanf("%d", &n); for(int i=0; i<n; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); for(int i=b; i<b+c; i++) { room[i] += a; } } int ans = 0; for(int i=0; i<200; i++) { ans = max(ans, room[i]); } printf("%d\n", ans); } return 0; }
走进世博园某信息通信馆,参观者将获得前所未有的尖端互动体验,一场充满创想和喜悦的信息通信互动体验秀将以全新形式呈现,从观众踏入展馆的第一步起,就将与手持终端密不可分,人类未来梦想的惊喜从参观者的掌上展开。
在等候区的梦想花园中,参观者便开始了他们奇妙的体验之旅,等待中的游客可利用手机等终端参与互动小游戏,与梦想剧场内的虚拟人物Kr. Kong 进行猜数比赛。当屏幕出现一个整数X时,若你能比Kr. Kong更快的发出最接近它的素数答案,你将会获得一个意想不到的礼物。
例如:当屏幕出现22时,你的回答应是23;当屏幕出现8时,你的回答应是7;若X本身是素数,则回答X;若最接近X的素数有两个时,则回答大于它的素数。
4 22 5 18 8
23 5 19 7
思路:素数筛选法,筛出其中的素数,然后输入,就看输入那个数本身是不是素数,是就输出,不是就往两边找,找到素数就输出(先往大的方向找)
AC代码:
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 1010; int prime[maxn]; int init() { memset(prime, 0, sizeof(prime)); for(int i=2; i<=maxn; i++) { if(prime[i] == 0) { prime[i] = 2; for(int j = i*i; j<maxn; j += i) prime[j] = 1; } } } int main() { init(); int n; scanf("%d", &n); while(n--) { int x; scanf("%d", &x); if(prime[x]==2) printf("%d\n", x); else for(int i=1; i<=x; i++) { if(prime[x+i] == 2) { printf("%d\n", x+i); break;} else if(prime[x-i] == 2) { printf("%d\n", x-i); break;} } } return 0; }
A公司是全球依靠的互联网解决方案提供商,也是2010年世博会的高级赞助商。它将提供先进的网络协作技术,展示其”智能+互联“的生活概念,同时为参观者提供高品质的个人体验和互动,以”信息通信,尽情城市梦想”为主题贯穿。借助奇幻的剧场大屏幕和特效,展现信息通信技术的应用前景,通过生动形象的故事,向观众展示沟通无限制的未来社会前景。
为此,A公司为世博园的N个区域建立了视频通信系统,其中每个区域建立一个基站,编号依次为1,2,3...,N。通过基站之间的通信线路为各区域的参观者提供视频服务。
已知在各基站之间已铺设了一些光纤通讯线路,这些线路覆盖了所有的区域,即任意两个区域都可以进行视频传递。但为了节约成本开支,目前只铺设了N-1条线路,同时为了减轻各基站的信息传递负载,每个基站最多有三条光纤通讯线路与之连接。
但在通信系统试运行期间,A公司发现当某个基站发生故障时,会导致其它区域之间无法进行信息传递。为了提高该通信网络的可靠性,A公司准备在基站之间再新铺设一些光纤线路,使得任意一个基站故障后,其它基站之间仍然可以通讯。
由于铺设线路的成本昂贵,A公司希望新增设的光纤线路越少越好。A公司请求Dr. Kong来完成这个任务
8 1 3 3 2 5 3 5 4 5 6 2 7 2 8
3
思路:就是一个图,找度为一的点,加一条路径可以去掉两个度为一的点,只要把所有度为一的点去掉即可
AC代码:
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 10005; int indeg[maxn]; int main() { int n; while(scanf("%d", &n) != EOF) { memset(indeg, 0, sizeof(indeg)); for(int i=1; i<n; i++) { int a, b; scanf("%d %d", &a, &b); indeg[a]++; indeg[b]++; } int sum = 0; for(int i=1; i<=n; i++) { if(indeg[i] == 1) sum++; } printf("%d\n", sum/2 + sum%2); } return 0; }
3 4 3 1 2 8 5 3 4 6 1 0 2 3
24
思路:简单贪心!!
AC代码:
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int a[25][25]; int main() { int n, m; memset(a, 0, sizeof(a)); scanf("%d %d", &n, &m); for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { scanf("%d", &a[i][j]); } } for(int i=2; i<=n; i++) a[i][1] += a[i-1][1]; for(int i=2; i<=m; i++) a[1][i] += a[1][i-1]; for(int i=2; i<=n; i++) { for(int j=2; j<=m; j++) { a[i][j] += max(a[i-1][j], a[i][j-1]); } } printf("%d\n", a[n][m]); return 0; }
Farmer John needs to travel to town to pick up K (1 <= K <= 100)pounds of feed. Driving D miles with K pounds of feed in his truck costs D*K cents.
It is best for John to buy one pound of feed from both the second and third stores. He must pay two cents to buy each pound of feed for a total cost of 4. When John travels from 3 to 4 he is moving 1 unit of length and he has 1 pound of feed so he must pay1*1 = 1 cents.
When John travels from 4 to 5 heis moving one unit and he has 2 pounds of feed so he must pay 1*2 = 2 cents. The total cost is 4+1+2 = 7 cents.
1
2 5 3
3 1 2
4 1 2
1 1 1
7
思路:也是简单贪心!!(不过是按每个feed的cost的从小到大排序,而不是按总的feed的cost排序,我就这样很蠢的WA了一次。。)
AC代码:
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int e; const int maxn = 105; struct node { int x; int f; int cost; }s[maxn]; bool cmp(node a, node b) { return (a.cost+e-a.x<b.cost+e-b.x); } int main() { int c; while(scanf("%d", &c) != EOF) { while(c--) { int k, n; scanf("%d %d %d", &k, &e, &n); for(int i=0; i<n; i++) scanf("%d %d %d", &s[i].x, &s[i].f, &s[i].cost); sort(s, s+n, cmp); int ans = 0, i = 0; while(k>0) { if(k >= s[i].f) { ans += (s[i].cost+e-s[i].x)*s[i].f; k -= s[i].f; } else { ans += (s[i].cost+e-s[i].x)*k; k = 0; } i++; } printf("%d\n", ans); } } return 0; }
Recently the auction house has introduced a new type of auction, the lowest price auction. In this new system, people compete for the lowest bid price, as opposed to what they did in the past. What an amazing thing! Now you could buy cool stuff with one penny. Your task is to write the software to automate this auction system.
First the auctioneer puts an upper limit on bid price for each item. Only positive price less than or equal to this price limit is a valid bid. For example, if the price limit is 100, then 1 to 100, inclusive, are all valid bid prices. Bidder can not put more than one bid for the same price on a same item. However they can put many bids on a same item, as long as the prices are different.
After all bids are set, the auctioneer chooses the winner according to the following rules:
(1). If any valid price comes from only one bidder, the price is a "unique bid". If there are unique bids, then the unique bid with the lowest price wins. This price is the winning price and the only bidder is the winning bidder.
(2). If there are no unique bids, then the price with fewest bids is the winning bid. If there are more than one price which has the same lowest bid count, choose the lowest one. This price is the winning price. The bidder who puts this bid first is the winning bidder.
Given the price limit and all the bids that happen in order, you will determine the winning bidder and the winning price.
30 7
Mary 10
Mary 20
Mary 30
Bob 10
Bob 30
Carl 30
Alice 23
The winner is Mary
The price is 20
思路:貌似是一个很常见的游戏,就是竞拍,给出价格,看谁的价格是唯一一个出价的且在唯一一个出价中最低的,如果不存在,就输出第一个拍出那个最低价的人。。
AC代码:
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; struct node { char st[10]; int price; }a[110]; int ci[1005]; int main() { int u, m; while(scanf("%d %d", &u, &m) != EOF) { memset(ci, 0, sizeof(ci)); for(int i=0; i<m; i++) { scanf("%s %d", a[i].st, &a[i].price); ci[a[i].price]++; } int p, flag = 1; for(int i=1; i<=u; i++) if(ci[i] == 1) { p = i; flag = 0; break; } if(flag) for(int i=1; i<=u; i++) if(ci[i] > 0) { p = i; break; } for(int i=0; i<m; i++) { if(a[i].price == p) { printf("The winner is %s\n", a[i].st); break; } } printf("The price is %d\n", p); } return 0; }
总结:省赛的题还是蛮水的,下次省赛好好耍!!