Cod sursa(job #1876896)
Utilizator | Data | 12 februarie 2017 18:37:32 | |
---|---|---|---|
Problema | 12-Perm | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("12perm.in");
ofstream fout("12perm.out");
int dp[15000005];
const int mod=1048576;
int main()
{
int n,l=6;
fin>>n;
dp[1]=1;dp[2]=2;dp[3]=6;dp[4]=12;
for(int i=5;i<=n;i++,l+=2)
dp[i]=(dp[i-1]+dp[i-3]+l)%mod;
fout<<dp[n];
return 0;
}