nicuvlad76

Untitled

Dec 10th, 2022
809
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <algorithm>
  4. # define M 100003
  5. using namespace std;
  6. ifstream fin("trickortreat.in");
  7. ofstream fout("trickortreat.out");
  8. ///a(n) = n*(2*n-1)*a(n-1) + (n-1)*n*a(n-2), a0=1, a1=0
  9.  
  10. int main()
  11. {
  12.   long long  a0,a1,a,n;
  13.   fin>>n;
  14.   a0=1, a1=0;
  15.   for(int i=2;i<=n;i++)
  16.   {
  17.       a=i*(2*i-1)*a1%M+(i-1)*i*a0%M;
  18.       a0=a1%M;
  19.       a1=a%M;
  20.   }
  21.   fout<<a;
  22.   return 0;
  23. }
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment