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;}
- 2017 ICPCECIC Make cubes
- 2017ICPCECIC
- 2017ICPCECIC北方邀请赛
- 2017 ICPCECIC Birthday present
- 1352 - Colored Cubes ---make
- 2017ICPCECIC MJF wants to work
- 2017 ICPCECIC 北方邀请赛 H MJF wants to work (贪心)
- 17.07.22 ICPCECIC Problem E
- Maigc Cubes:2017 Works Application笔试
- Kickstart Round A 2017 Problem C. Space Cubes
- Marching Cubes
- Marching Cubes
- Colored Cubes
- Risky cubes
- Perfect Cubes
- Colored Cubes
- Playing Cubes
- Colored Cubes
- python找质数对
- Linux: 通过SUID权限来实现“封装”
- C# 正则表达式
- libevent实现https服务器
- Java web开发,在一个jsp里放太多java代码的后果,摘自 java web轻量级开发面试教程
- 2017 ICPCECIC Make cubes
- C++中成员函数的重载、覆盖和隐藏的区别
- Python多线程---threading
- WeakHashMap
- Java的final
- 支持向量机(SVM)初级
- java快速排序和三向切分的快速排序
- IAP
- android 无标题栏 样式