Created
September 7, 2016 01:34
-
-
Save ssavi/c282ea461959f31104ccff04552617e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2))) | |
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2))) | |
#define CLR(a) a.clear() | |
#define VCLR(a, n) for(int i=0; i<=n+3; i++) a[i].clear() | |
#define SIZE(a) a.size() | |
#define ERASE(a, b) memset(a, b, sizeof a) | |
#define PB(a, b) a.push_back(b) | |
#define PB2(a,i,b) a[i].push_back(b) | |
#define LL long long | |
#define DBG cout<<"I Am Here"<<endl | |
#define DBGA(a) cout<<a<<endl | |
#define DBGI(b,a) cout<<b<<' '<<a<<endl | |
#define DBGL(i,s,e,b) or(int i=s; i<=e; i++) cout<<b<<endl | |
#define INF 1e9 | |
#define INV 1e-6 | |
#define sll(a) scanf("%I64d", &a) | |
#define pll(a) printf("%I64d\n", a) | |
#define si(a) scanf("%d", &a) | |
#define pii pair<int,int> | |
#define MAX 100006 | |
#define CASE(i) printf("Case %d:\n", i); | |
#define PI acos(-1) | |
#define piis pair<int, string> | |
#define fast1 ios_base::sync_with_stdio(false); | |
#define fast2 cin.tie(0) | |
using namespace std; | |
LL F[1000007], P[1000007]; | |
void precal() | |
{ | |
F[3] = 0; P[3] = 0; | |
LL var = 0; | |
for(int i=4; i<=1000000; i++) | |
{ | |
if(i%2==0) | |
{ | |
var++; | |
P[i] = P[i-1] + var; | |
F[i] = F[i-1] + P[i]; | |
} | |
else | |
{ | |
P[i] = P[i-1] + var; | |
F[i] = F[i-1] + P[i]; | |
} | |
} | |
} | |
int main() | |
{ | |
precal(); | |
int n; | |
while(scanf("%d", &n) && n>=3) | |
{ | |
printf("%lld\n", F[n]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment