昨天的CCPC杭州怎么说好的还是取消了,那么今天就来玩玩这个总决赛
Dogs and Cages
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Special Judge
One day, Jerry noticed that some dogs were in the cage with the same number of themselves while others were not. Jerry would like to know what’s the expected number of dogs that are NOT in the cage with the same number of themselves.
Each test case contains only one number N, indicating the number of dogs and cages.
1≤T≤105
1≤N≤105
y will be considered correct if it is within an absolute or relative error of 10?6 of the correct answer.
#include<bits/stdc++.h> using namespace std; int main() { int T,ca=0; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); printf("Case #%d: %d\n",++ca,n-1); } return 0; }
Tiger owns a stationery factory which produces sketchpad, so he wants to let all the competitions use the sketchpads produced by his factory privately. The Bear plans to hold N painting competitions, and informs Tiger of the number of competitors who are ready for each competition. One competitor needs only one sktechpad in one competition. For each competition, at least 10% extra sketchpads are required as backup just in case.
The Tiger assigns you, his loyal subordinate to calculate the minimum number of sketchpads produced
by his factory.
For each test case, the first line contains an integer N, where N is the number of competitions. The next line contains N integers a1,a2,...,aN representing the number of competitors in each competition.
1≤T≤100
1≤N≤1000
1≤ai≤100
#include<bits/stdc++.h> using namespace std; int main() { int T,ca=0; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); int s=0; for(int i=1;i<=n;i++) { int x; scanf("%d",&x); s+=x+x/10+(x%10!=0); } printf("Case #%d: %d\n",++ca,s); } return 0; }
Rich Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
God Sheep is going to play K sets of badminton games. For each set, anyone who wins at least 11 points and leads by at least 2 points will win this set. In other words, normally anyone who wins 11 points first will win the set. In case of deuce (E.g. 10 points to 10 points), it’s necessary to lead by 2 points to win the set.
Mr. Panda is really good at badminton so he could make each point win or lose at his will. But he has no money at the beginning. He need to earn money by losing points and using the money to win points.
Mr. Panda cannot owe God Sheep money as god never borrowed money. What’s the maximal number of sets can Mr. Panda win if he plays cleverly?
Each test case contains 3 numbers in one line, X, Y , K, the number of dollars earned by losing a point, the number of dollars paid by winning a point, the number of sets God Sheep is going to play.
1≤T≤105.
1≤X,Y,K≤1000.
#include<bits/stdc++.h> using namespace std; int main() { int T,ca=0; scanf("%d",&T); while(T--) { int x,y,k,s; scanf("%d%d%d",&x,&y,&k); if(x>y) s=k; else s=11*k*x/(11*y+2*x); printf("Case #%d: %d\n",++ca,s); } return 0; }
Knightmare
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Recall that a knight can jump in 8 directions. Each direction consists of two squares forward and then one squaure sidways.
After N jumps, how many squares can possibly be claimed as territory of the knight? As N can be really large, this becomes a nightmare to the knight who is not very good at math. Can you help to answer this question?
Each test case contains only one number N, indicating how many times the knight jumps.
1≤T≤105
0≤N≤109
#include<bits/stdc++.h> using namespace std; int main() { int T,ca=0; scanf("%d",&T); int a[5]={1,9,41,109,205}; while(T--) { unsigned long long n; scanf("%llu",&n); printf("Case #%d: ",++ca); if(n<5) printf("%d\n",a[n]); else printf("%llu\n",(n*14-6)*n+5); } return 0; }
Alice’s Stamps
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
There are N different kinds of stamps that exist in the world; they are numbered 1 through N. However, stamps are not sold individually; they must be purchased in sets. There are M different stamp sets available; the ith set contains the stamps numbered Li through Ri. The same stamp might appear in more than one set, and it is possible that one or more stamps are not available in any of the sets.
All of the sets cost the same amount; because Alice has a limited budget, she can buy at most K different sets. What is the maximum number of different kinds of stamps that Alice can get?
Each test case begins with a line containing three integers: N, M, and K: the number of different kinds of stamps available, the number of stamp sets available, and the maximum number of stamp sets that Alice can buy.
M lines follow; the ithoftheselinesrepresentsthei^{th} stamp set and contains two integers, Li and Ri, which represent the inclusive range of the numbers of the stamps available in that set.
1≤T≤100
1≤K≤M
1≤N,M≤2000
1≤Li≤Ri≤N
有一点没搞对,都没来得及交,就是一个简单的dp
#include<bits/stdc++.h> using namespace std; int dp[2005][2005]; int l[2005],f[2005]; int main() { int T,ca=0; scanf("%d",&T); while(T--) { memset(l,0,sizeof l); int n,m,k; scanf("%d%d%d",&n,&m,&k); for(int i=0; i<m; i++) { int x,y; scanf("%d%d",&x,&y); l[x]=max(l[x],y); } int ans=0; memset(dp,0,sizeof dp); memset(f,0,sizeof f); for(int i=1; i<=n; i++) { for(int j=0; j<k; j++) { if(l[i]) { dp[i][j]+=(f[i]==0); dp[l[i]][j+1]=dp[i][j]+l[i]-i; f[l[i]]=1; } dp[i+1][j]=max(dp[i][j],dp[i+1][j]); } ans=max(ans,dp[i][k]); } printf("Case #%d: %d\n",++ca,ans); } return 0; }