2017 ICPCECIC Make cubes

来源:互联网 发布:mac解除icloud 编辑:程序博客网 时间:2024/06/05 10:53

题目描述

When he was a little boy, Jieba had always been interested in geometry. One time, he got many pieces of colored square cards. For each color, he had as many pieces as he wanted. At that time, he decided to make some cubes using these cards. He wanted to know how many kinds of cubes could he make? (if one kind of cube can rotate to another kind, they will be seen the same)

输入

Every line of the input file defines a test case and contains one integer: the number of available colors n (0

题意

题意倒是很好懂,就是给一个六面体,然后给你n种颜色,问n种颜色可以涂成不同的六面体的个数。六面体可以旋转,旋转相同也算是相同。


思路

开始是直接暴力求几个数找规律,但是吧,六层循环写完了以后,在判重那里出了点问题。
横着转,竖着转。一开始只考虑了这两者两种情况,还落了一种斜着翻转的情况,所以一直连两种颜色都跑不对。
改进之后,暴力跑出一种到六种颜色的方案数分别是1,10,57,240,800,2226。
神TM看得出规律。
最后也没写出来,赛后学长说啊,六种以上就是n种颜色选一种乘上一种颜色的方案数,加上n种颜色选两种颜色乘上两种颜色的方案数,加上…以此类推,因为六面体最多只能涂六种颜色,所以,只要加到六种颜色就好了。
注意:
因为数据范围,所以要用long long 存ans和中间值。


代码

#include <iostream>#include <cstdio>#include <algorithm>#include <set>#include <queue>using namespace std;typedef long long ll;const ll MOD = 1000000007;long long solve (int n,int x){     long long t,b;     t=1;     b=1;     for(int i=n,j=0;j<x;j++,i--)     {         b*=j+1;         t*=i;     }     return (t/b)%MOD;}int main() {    int n;    long long t,ans;    int a[7]={1,8,30,68,75,30};    int b[7]={1,10,57,240,800,2226};    while(scanf("%d",&n)!=EOF)    {        if(n<=6)            printf("%d\n",b[n-1]);        else        {            ans=0;            for(int i=0;i<6;++i)            {                t=solve(n,i+1);                ans+=t*a[i];                ans%=MOD;            }            printf("%lld\n",ans);        }    }    return 0;}