Question B: http://bailian.openjudge.cn/exam/1511/2/
The problem WA once, and then understand clearly test instructions after the correct,
Analysis of the six models of the products occupy the box as follows: 6*6 's products each occupy a complete box, and there is no free space; 5*5 's products occupy a new box each, and leave 11 free space for the products that can hold 1*1; 4*4 's products occupy a new box each, And left 5 can be filled with 2*2 of the product of the spare space, 3*3 product situation is more complex, the first 3*3 products can not be placed in the original 5*5 or 4*4 box, then must be for the 3*3 of the product to open a new box, the number of newly opened box equals the number of 3*3 products divided by 4 upward rounding At the same time we need to discuss the new box for 3*3 products, the remaining space can be filled with how many 2*2 and 1*1 products (here if there is room to put 2*2 products, we will take it into the 2*2 of free space, until the 2*2 products are all loaded, if there is 2*2 space surplus, and convert them to the remaining space of the 1*1). We can discuss the situation in the new box opened for 3*3 the remaining vacancies in a total of four cases: the first, the number of 3*3 products is exactly 4 multiples, so there is no free space; the second, the number of 3*3 products is a multiple of 4 plus 1, then there are 5 2*2 and 7 1*1 slots Third, the number of 3*3 products is a multiple of 4 plus 2, then there are 3 2*2 vacancy and 6 1*1 vacancy; Fourth, the number of 3*3 products is 4 multiples plus 3, then there are 1 2*2 slots and 5 1*1 slots; After finishing the 3*3 product, you can compare the remaining 2*2 The number of vacant and 2*2 products, if the number of products, will be 2*2 all fill, and then for 2*2 products open new box, while calculating the new box 1*1 empty, if the remaining vacant, will 2*2 all the products into the 2*2 of empty space, and then the remaining 2*2 of the vacancy converted into 1*1 empty , the final processing 1*1 products, compare 1*1 vacancy and 1*1 of the product number, if more space, will 1*1 products all fill in empty space, otherwise, first will 1*1 empty fill, and then for 1*1 products open new box.
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <vector>6 using namespacestd;7 intA1,a2,a3,a4,a5,a6;8 intMain ()9 {Ten intN//Number of boxes One intX//1*1 number of boxes A intY//2*2 number of boxes - intt[4]={0,5,3,1};//3*3 can accommodate the number of 2*2 - while(cin>>a1>>a2>>a3>>a4>>a5>>a6) the { -n=0; - if(a1==0&&a2==0&&a3==0&&a4==0&&a5==0&&a6==0) - Break; +n+=a6+a5+a4+ (a3+3)/4; -y=5*a4+t[a3%4]; + if(a2>y) An+= (a2-y+8)/9; atx= $*n- $*a6- -*a5- -*a4-9*a3-4*A2; - if(a1>x) -n+= (a1-x+ *)/ $; -cout<<n<<Endl; - } - return 0; in}
View Code
Question C: http://bailian.openjudge.cn/exam/1511/3/
This problem is very water, do not write a problem, directly paste code
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <string>5#include <cmath>6 using namespacestd;7 Const intmaxn=101;8 intA[MAXN];9 intMain ()Ten { One intT; A intN; -Cin>>T; - while(t--) the { -Cin>>N; -Memset (A,0,sizeof(a)); - for(intI=1; i<=n;i++) + { - for(intj=i;j<=n;j++) + if(j%i==0) Aa[j]=!A[j]; at } - intCnt=0; - for(intI=1; i<=n;i++) - if(A[i]) -++CNT; -cout<<cnt<<Endl; in } -}
View Code
Hundred Practice Personal Test