13/9/5 组队赛

来源:互联网 发布:怎么淘宝客推广 编辑:程序博客网 时间:2024/06/05 07:50
E:Coffin Tiles

就是找一个数的因数,打表即可,可是竟然忘记了用freopen,不晓得打表结果放哪,哎。。

#include<iostream>#include<cstdio>#include<string>#include<cstring>#include<algorithm>#include<cmath>using namespace std;#define mod 1000005int a[mod];int b[1000]={0,1,4,12,24,36,60,192,120,180,240,576,360,1296,900,720,840,9216,1260,786432,1680,2880,15360,3600,2520,6480,61440,6300,6720,0,5040,0,7560,46080,983040,25920,10080,0,32400,184320,15120,44100,20160,0,107520,25200,0,0,27720,233280,45360,0,430080,129600,50400,414720,60480,0,0,921600,55440,0,0,100800,83160,0,322560,0,176400,0,181440,0,110880,0,0,226800,0,0,0,0,166320,352800,0,0,221760,0,0,0,967680,0,277200,0,0,0,0,705600,332640,0,0,0,498960,0,0,0,0,907200,0,0,554400,0,0,0,665280,0,0,0,0,0,0,0,720720};int vis[120];int main(){    int T;    int n;    cin>>T;    while(T--)    {        cin>>n;        if(n>120||b[n]==0)            cout<<"Too big"<<endl;        else            cout<<b[n]<<endl;    }    return 0;}/*int main(){    freopen("E:\\out.txt","w",stdout);    memset(a,0,sizeof(a));    int mx=0;    for(int i=1; i<1000005; i++)    {        for(int j=1; j<=sqrt(i); j++)        {            if(i%j==0)                a[i]++;        }        mx=max(a[i],mx);    }    //cout<<mx<<endl;   //mx=120;    for(int i=1; i<=120; i++)    {        for(int j=1; j<=1000000; j++)        {            if(a[j]==i)            {                b[i]=j;                break;            }        }    }    for(int i=1; i<=120; i++)        cout<<b[i]<<",";    return 0;}*/

D:This is Halloween: Saving Money
可以说这道题读不懂吗,但读懂了就是公式问题。所以,把题目放这吧!

The Mayor of Halloween Town was always concerned about saving money. When the Pumpkin King,Jack Skelington decided to try his hand at stealing Christmas again, the mayor began trying to cut corners wherever he could to afford it. They were in a recession,after all! When thegreat Jack commanded him to order enough wrapping paper for all the presents, the Mayor wanted to make sure he would only the absolute minimum amount. In order to do that, he has asked you, the local computer ghoul to write a problem to calculate the amount of wrapping paper that each of the different types of gifts would take. Thankfully for you, all of the gifts are able to fit in different sizes of rectangular boxes (The vampire trio, who is in charge of presents this year, got their start in manufacturing things while interns at Ikea). Each present can be represented by a name, and the three dimensions of the box a, b, c (0 < a <= b <= c) in frightometers.The procedure for wrapping the gift is first, a large sheet of wrapping paper is laid on a flat surface. Then, the box is placed on the wrapping paper with one of its 'bc' faces resting on the wrapping paper. The wrapping paper is folded around the four 'c' edges and the excess is cut off, leaving a 3 frightometer wide overlap on one of the 'ac' faces (shown shaded in the figure). At this point, the wrapping paper has the form of a long rectangular tube.Now more wrapping paper is cut off at the two ends of the tube. It is cut flush with the 'a' edges. Along the 'b' edges, rectangular flaps remain. These rectangular flaps are cut so that when they are folded along the 'b' edges, they cover the two 'ab' faces with a 3 frightometer wide overlap (overlapping areas shown shaded in the figure). The excess paper can be recycled (The Shadow on theMoon at night is an accomplished paper maker!), so that isn't to be taken into account. Calculate the amount of paper, in square frightometers that each box needs in order to be properly wrapped

Input

Input will begin with a single line containing a single integer, n > 0, where n is the number types of boxes you need to process. The following n lines start with the name of a product, in single quotes followed by three integers, a, b and c which represent the three dimensions of the package, as illustrated in the picture above. Following the dimensions, a number of significant digits to include inthe answer. The number of significant digits will never be greater than the number of digits in the answer. None of the dimensions will be greater than 10,000.

Output

Output will consist of n lines of the form:"The Present" requires "total paper area" square frightometers of paper to wrap

Sample Input

5'Kingdom Hearts III: When will it ever come out?' 1 2 3 1'Killer Bunnies' 7 14 21 2'Living head of Joseph Mengele' 34 81 101 1'Barney and Friends: The complete Series' 1 7 11 3'Abba: Greatest Hits' 45 78 650 5

Sample Output

Kingdom Hearts III: When will it ever come out? requires 40 square frightometers of paper to wrapKiller Bunnies requires 1200 square frightometers of paper to wrapLiving head of Joseph Mengele requires 20000 square frightometers of paper to wrapBarney and Friends: The complete Series requires 265 square frightometers of paper to wrapAbba: Greatest Hits requires 169330 square frightometers of paper to wrap

代码:
#include<iostream>#include<cstdio>#include<string>#include<cstring>#include<algorithm>#include<cmath>using namespace std;string s;int main(){    int n;    int a,b,c,k;    char cc;    cin>>n;    //getchar();    int ret=0;    int sum;    while(n--)    {        s="";        sum=0;        ret++;        cin>>cc;        while(cc=getchar())  //多加了一个等号。        {            if(cc=='\'')                break;            s+=cc;        }        cin>>a>>b>>c>>k;        if(a>b)            swap(a,b);        if(a>c)            swap(a,c);        if(b>c)            swap(b,c);        sum+=(a*b*2+a*c*2+b*c*2+6*b+3*c);        int num=0;        int ss=sum;        while(ss!=0)        {            num++;            ss/=10;        }        int ans=pow(10,num-k);        sum=sum/ans*ans;        cout<<s<<" requires "<<sum<<        " square frightometers of paper to wrap"<<endl;    }    return 0;}