Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <algorithm>
- # define M 100003
- using namespace std;
- ifstream fin("trickortreat.in");
- ofstream fout("trickortreat.out");
- ///a(n) = n*(2*n-1)*a(n-1) + (n-1)*n*a(n-2), a0=1, a1=0
- int main()
- {
- long long a0,a1,a,n;
- fin>>n;
- a0=1, a1=0;
- for(int i=2;i<=n;i++)
- {
- a=i*(2*i-1)*a1%M+(i-1)*i*a0%M;
- a0=a1%M;
- a1=a%M;
- }
- fout<<a;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment