2017 ICPCECIC Make cubes

题目描述

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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

渴鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值