CSUOJ: Training Team Team Plan

2022-12-27   ES  

Search for such a formula on OEIS, plus the multiplication method, it is AC, it is unknown. Essence Essencehttp://oeis.org/A005773

Question link:http://www.51nod.com/contest/problem.html#!problemId=1556

// Calculate .cpp 
 #include <bits/stdc ++. h> 
 #Define ll long long 
 #Define lson l, m, rt << 1 
 #Define rson m+1, r, rt << 1 | 1 
 #Define Pi 3.1415926535897932626 
 #Define exit exit (0); 
 #Define pause system ("pause"); 
 #Define Debug Puts ("Here is a bug"); 
 #Define sync_close ios :: sync_with_stdio (false); 
 #Define What_IS (X) COUT << #x << "is" << x << Endl; 
 #Define Clear (name, init) Memset (name, init, sizeof (name)); 
 const double Eps = 1E-8; 
 const int Maxn = (int) 1E6 + 5; 
 const LL MOD = 1000000007LL; 
 using namespace std; 

 Ll a [maxn]; 

 void ex_gcd (ll a, ll b, ll & x, ll & y) { 
     if (b == 0) { 
         x = 1; y = 0; 
         Return; 
     } 
     ex_gcd (b, a % b, y, x); 
     y -= x * (a/b); 
     Return; 
 } 
 int Main (int ARGC, Char Const *Argv []) {) { 
 #ifndef online_judge 
     Freopen ("D: \\ DISK_SYNCHRONOUS \\ Programs \\ ACM \\ Input.txt", "R", "R", " 
 #Endif 
     int n; cin >> n; 
     a [1] = 1; a [2] = 2; 
     for (int i = 3; i <= n; i ++) { 
         a [i] = 2*a [i-1] % mod; 
         Ll x, y; 
         ex_gcd (i, mod, x, y); 
         x = (x + mod) % mod; 
         a [i] = (a [i] + 3*(i-2)*a [i-2]%mod*x%mod)%mod; 
     } 
     COUT << A [n] << Endl; 
     Return 0; 
 }

source

Related Posts

IDEA convenient operation and configuration

javaee Learning Log (52): Response object, file download case, verification code case

Oracle Clob field Insertation The character is too long

python scrapy Explanation

CSUOJ: Training Team Team Plan

Random Posts

JSOUP parsing the error of the file path of the XML report, perfect solution. Patriotic XML uses JSOUP1. Use JSOUP to complete the analysis of Student.xml, and give the parsed data to the Student object, and finally output the object on the console.

Linux, the previous N IPPAN with the highest number of visits according to the visits log

IDEA convenient operation and configuration

5 Team-Team Mission 5: Project Summary CHUU

The BIOS setting hard disk of each brand notebook is compatible mode (IDE) method (transfer)