2014
03-03

GCC

The GNU Compiler Collection (usually shortened to GCC) is a compiler system produced by the GNU Project supporting various programming languages. But it doesn’t contains the math operator “!”.
In mathematics the symbol represents the factorial operation. The expression n! means "the product of the integers from 1 to n". For example, 4! (read four factorial) is 4 × 3 × 2 × 1 = 24. (0! is defined as 1, which is a neutral element in multiplication, not multiplied by anything.)
We want you to help us with this formation: (0! + 1! + 2! + 3! + 4! + … + n!)%m

The first line consists of an integer T, indicating the number of test cases.
Each test on a single consists of two integer n and m.

The first line consists of an integer T, indicating the number of test cases.
Each test on a single consists of two integer n and m.

1
10 861017

593846

/*

*/
#define LOCAL
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<string>
#include<algorithm>
#include<ctime>
#include<stack>
#include<queue>
#include<vector>
#define N 10005
using namespace std;
int main()
{
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

long long t=1,ans,i,ncase,m,n,nlen,mlen;string str;
cin>>ncase;
while(ncase--)
{
//数据处理
cin>>str>>m;
nlen=str.size();
t=m;mlen=0;
while(t){t=t/10;mlen++;}
t=1;n=0;
for(i=nlen-1;(i>=0&&i>=nlen-8);i--)
{
n+=(str[i]-'0')*t;
t*=10;
}
if(nlen>mlen||n>m) {n=m;n--;}
//计算
ans=1;t=1;
for(i=1;i<=n;i++)
{
t=(t*i)%m;//防止数据溢出
ans=(ans+t)%m;
}
ans%=m;//防止出现m==1出现时n%m==1的情况
cout<<ans<<endl;
}
return 0;
}

1. 被闹，张起灵明明就是男一，吴起到记述作用，因为三叔全文用了“我”这一人称，所以相当于吴邪的***家笔记，意思就是三叔写了吴邪的笔记一样，所以张起灵是男一

2. #include <cstdio>
#include <algorithm>

struct LWPair{
int l,w;
};

int main() {
//freopen("input.txt","r",stdin);
const int MAXSIZE=5000, MAXVAL=10000;
LWPair sticks[MAXSIZE];
int store[MAXSIZE];
int ncase, nstick, length,width, tmp, time, i,j;
if(scanf("%d",&ncase)!=1) return -1;
while(ncase– && scanf("%d",&nstick)==1) {
for(i=0;i<nstick;++i) scanf("%d%d",&sticks .l,&sticks .w);
std::sort(sticks,sticks+nstick,[](const LWPair &lhs, const LWPair &rhs) { return lhs.l>rhs.l || lhs.l==rhs.l && lhs.w>rhs.w; });
for(time=-1,i=0;i<nstick;++i) {
tmp=sticks .w;
for(j=time;j>=0 && store >=tmp;–j) ; // search from right to left
if(j==time) { store[++time]=tmp; }
else { store[j+1]=tmp; }
}
printf("%dn",time+1);
}
return 0;
}