转载请注明出处:http://blog.csdn.net/u012860063
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4450
代码如下:
#include <cstdio> int main() { int n, minn, maxx; int t, cas = 0, i, j,tt; long long sum = 0, tmp, mod = 10000000000007; while(~scanf("%d",&t)) { while(t--) { scanf("%d%d%d",&n,&minn,&maxx); sum = 0, tt = n*n, tmp = 1; for(i = 1; i <=minn; i++) { tmp*=tt; tmp%=mod; tt--; } sum = tmp%mod; for(i = minn+1; i <= maxx; i++) { tmp*=tt; tmp%=mod; tt--; sum+=tmp; sum%=mod; } printf("Case %d: %lld\n",++cas,sum); } } return 0; }
UVA 12712 Pattern Locker(简单排列组合数学题),布布扣,bubuko.com
UVA 12712 Pattern Locker(简单排列组合数学题)
原文地址:http://blog.csdn.net/u012860063/article/details/36202773